package com.eorchis.module.trainingclass.ui.controller;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.io.FilenameUtils;
import org.hibernate.Hibernate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.eorchis.components.attachment.domain.Attachment;
import com.eorchis.components.attachment.service.IAttachmentService;
import com.eorchis.components.attachment.service.UploadConfig;
import com.eorchis.components.attachment.ui.commond.AttachmentCommond;
import com.eorchis.constants.DeptConstants;
import com.eorchis.constants.RoleConstants;
import com.eorchis.core.service.IBaseService;
import com.eorchis.core.servicetemplate.treetemplate.jsonbean.JsonTreeBean;
import com.eorchis.core.springext.mvc.SessionConstant;
import com.eorchis.core.ui.commond.ResultState;
import com.eorchis.core.ui.commond.converter.IQueryCommondAttributeConverter;
import com.eorchis.core.ui.controller.AbstractBaseController;
import com.eorchis.module.TrainingConstants;
import com.eorchis.module.basedata.domain.BaseData;
import com.eorchis.module.classauditinfo.domain.ClassAuditInfo;
import com.eorchis.module.classauditinfo.service.IClassAuditInfoService;
import com.eorchis.module.classauditinfo.ui.commond.ClassAuditInfoQueryCommond;
import com.eorchis.module.classauditinfo.ui.commond.ClassAuditInfoValidCommond;
import com.eorchis.module.classcourse.domain.ExportClassCourseBean;
import com.eorchis.module.classcourse.querybean.ClassCourseQueryBean;
import com.eorchis.module.classcourse.service.IClassCourseService;
import com.eorchis.module.classcourse.ui.commond.ClassCourseQueryCommond;
import com.eorchis.module.classplanapply.bean.ClassPlanApplyQueryBean;
import com.eorchis.module.classplanapply.service.IClassPlanApplyService;
import com.eorchis.module.classplanapply.ui.commond.ClassPlanApplyQueryCommond;
import com.eorchis.module.classuser.dao.IClassUserDao;
import com.eorchis.module.classuser.ui.commond.ClassUserQueryCommond;
import com.eorchis.module.department.domain.Department;
import com.eorchis.module.department.domain.DepartmentTreeCondition;
import com.eorchis.module.department.manager.IDepartmentTreeManager;
import com.eorchis.module.department.service.IDepartmentTreeService;
import com.eorchis.module.department.ui.commond.DepartmentTreeCommond;
import com.eorchis.module.department.ui.commond.DepartmentValidCommond;
import com.eorchis.module.remind.service.IRemindService;
import com.eorchis.module.reminduserlink.service.IRemindUserLinkService;
import com.eorchis.module.role.domain.Role;
import com.eorchis.module.trainingclass.domain.BaseAttachment;
import com.eorchis.module.trainingclass.domain.BaseUserBean;
import com.eorchis.module.trainingclass.domain.ClassScopeDepartment;
import com.eorchis.module.trainingclass.domain.ClassSignUpDepartment;
import com.eorchis.module.trainingclass.domain.ExportClassBean;
import com.eorchis.module.trainingclass.domain.TrainingClass;
import com.eorchis.module.trainingclass.domain.TrainingClassAndCourseExport;
import com.eorchis.module.trainingclass.domain.TrainingClassExport;
import com.eorchis.module.trainingclass.domain.TrainingClassPartFieldUpdateBean;
import com.eorchis.module.trainingclass.domain.TrainingClassSheet;
import com.eorchis.module.trainingclass.domain.TrainingClassStatisticsExport;
import com.eorchis.module.trainingclass.querybean.TrainingClassQueryBean;
import com.eorchis.module.trainingclass.querybean.YearBaseDate;
import com.eorchis.module.trainingclass.service.ITrainingClassService;
import com.eorchis.module.trainingclass.ui.commond.TrainingClassQueryCommond;
import com.eorchis.module.trainingclass.ui.commond.TrainingClassValidCommond;
import com.eorchis.module.user.domain.User;
import com.eorchis.module.util.DateUtil;
import com.eorchis.utils.StringUtils;
import com.eorchis.utils.excelutil.ExcelIO;
import com.eorchis.utils.excelutil.ExcelIOFactory;
import com.eorchis.utils.excelutil.export.bo.Sheet;
import com.eorchis.utils.utils.PropertyUtil;

/**
 * Title: TrainingClassController<br>
 * Description: 培训班信息管理控制器<br>
 * Company: GoldGov<br>
 * Copyright @ 2012 GoldGov .All rights reserved.<br>
 * 
 * @author Max
 * @createDate 2014-12-9
 * @version $Revision$
 */
@Controller("trainingClassController")
@RequestMapping(value = TrainingClassController.MODULE_PATH)
public class TrainingClassController extends AbstractBaseController<TrainingClassValidCommond, TrainingClassQueryCommond> {
	// 模块页面根路径
	public static final String MODULE_PATH = "/module/trainingclass";
	// 培训班信息接口
	@Autowired
	@Qualifier("com.eorchis.module.trainingclass.service.impl.TrainingClassServiceImpl")
	private ITrainingClassService trainingClassService;

	@Resource(name = "com.eorchis.module.classuser.dao.impl.ClassUserDaoImpl")
	private IClassUserDao classUserDao;

	// 提醒用户关联表接口
	@Resource(name = "com.eorchis.module.reminduserlink.service.impl.RemindUserLinkServiceImpl")
	private IRemindUserLinkService remindUserLinkService;

	@Autowired
	@Qualifier("com.eorchis.module.department.manager.impl.DepartmentTreeManagerImpl")
	private IDepartmentTreeManager departmentTreeSyncManager;

	// 班级计划报名接口
	@Autowired
	@Qualifier("com.eorchis.module.classplanapply.service.impl.ClassPlanApplyServiceImpl")
	private IClassPlanApplyService classPlanApplyService;

	@Autowired
	@Qualifier("attributeConverter")
	private ArrayList<IQueryCommondAttributeConverter> attributeConverter;

	// 提醒表接口
	@Resource(name = "com.eorchis.module.remind.service.impl.RemindServiceImpl")
	private IRemindService remindService;

	@Autowired
	@Qualifier("com.eorchis.module.department.service.impl.DepartmentTreeServiceImpl")
	private IDepartmentTreeService departmentTreeService;
	// 班级课程维护接口
	@Autowired
	@Qualifier("com.eorchis.module.classcourse.service.impl.ClassCourseServiceImpl")
	private IClassCourseService classCourseService;
	// 班级审核信息接口
	@Autowired
	@Qualifier("com.eorchis.module.classauditinfo.service.impl.ClassAuditInfoServiceImpl")
	private IClassAuditInfoService classAuditInfoService;
	// 附件上传下载接口
	@Autowired
	@Qualifier("attachmentService")
	private IAttachmentService attachmentService;

	public IBaseService getService() {
		return trainingClassService;
	}

	public String getModulePath() {
		return MODULE_PATH;
	}

	/**
	 * 预添加培训班
	 * 
	 * @param model
	 * @param request
	 * @return
	 * @throws Exception
	 * @author Max
	 * @date 2014-12-09
	 */
	@RequestMapping(value = "/preAddTraining")
	public String preSave(@ModelAttribute("resultList") TrainingClassValidCommond vCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		/*
		 * 预添加数据1.培训机构(管理员的管理范围)2.主办单位
		 */
		// 1
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		vCommond.setTrainingDeptId(d.getDeptID());
		vCommond.setTrainingDeptName(d.getDeptName());
		// 2
		vCommond.setSponsorName("中共中央组织部、中央直属机关工作委员会、中央国家机关工作委员会");
		vCommond.setClassnameUnit("中央和国家机关司局级干部选学");

		Calendar a = Calendar.getInstance();
		Integer currYear = a.get(Calendar.YEAR);
		if (currYear == 2014) {
			vCommond.setClassnameYear((currYear + 1) + "");
		} else {
			vCommond.setClassnameYear((currYear) + "");
		}
		vCommond.setClassnamePeriod("一");

		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/add";
	}

	/**
	 * 预添加的获取年份
	 * 
	 * @param model
	 * @param request
	 * @param TrainingClassConditionWrap
	 * @param response
	 * @return
	 * @author Max
	 * @throws Exception
	 * @date 2014-12-09
	 */
	@RequestMapping(value = "/getYearData")
	public String getYearData(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		Calendar a = Calendar.getInstance();
		Integer currYear = a.get(Calendar.YEAR);// 得到当前年
		List<YearBaseDate> allYear = new ArrayList<YearBaseDate>();
		allYear.add(new YearBaseDate((currYear) + ""));
		allYear.add(new YearBaseDate((currYear + 1) + ""));
		allYear.add(new YearBaseDate((currYear + 2) + ""));
		allYear.add(new YearBaseDate((currYear + 3) + ""));
		allYear.add(new YearBaseDate((currYear + 4) + ""));
		allYear.add(new YearBaseDate((currYear + 5) + ""));
		allYear.add(new YearBaseDate((currYear + 6) + ""));
		allYear.add(new YearBaseDate((currYear + 7) + ""));
		allYear.add(new YearBaseDate((currYear + 8) + ""));
		allYear.add(new YearBaseDate((currYear + 9) + ""));
		allYear.add(new YearBaseDate((currYear + 10) + ""));
		allYear.add(new YearBaseDate((currYear + 11) + ""));
		queryCommond.setResultList(allYear);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return "";
	}

	public Date addDay(String date, int days) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar cd = Calendar.getInstance();
		cd.setTime(sdf.parse(date));
		cd.add(Calendar.DATE, days);// 增加一天
		return cd.getTime();
	}

	/**
	 * 新增培训班（中组部）
	 * 
	 * @author YanDong
	 * @createDate 2016-1-4
	 */
	@RequestMapping(value = "/addTraining")
	public String addTraining(@ModelAttribute("result") @Valid TrainingClassValidCommond vCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		
		// 判断 指定报名单位是否为空
		for (String s : vCommond.getSignUpDepartmentIds()) {
			if ("".equals(s)) {
				vCommond.setSignupOr(TrainingClass.SIGNUPOr_Y);
				break;
			} else {
				vCommond.setSignupOr(TrainingClass.SIGNUPOr_N);
				break;
			}
		}
		// 当前管理范围
		Role currentrole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		// 当前管理部门
		Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// 当时超级管理员的时候替换名字
		if (PropertyUtil.objectNotEmpty(currentrole) && currentrole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN)) {
			if (DeptConstants.DEPT_NAME_CONVERT.containsKey(d.getDeptName())) {
				vCommond.setSponsorName(DeptConstants.DEPT_NAME_CONVERT.get(d.getDeptName()));
			}
		}

		/**
		 * 判断编号的位数是否是9位
		 */
		// if (!PropertyUtil.objectNotEmpty(vCommond.getClassNum()) ||
		// vCommond.getClassNum().length() != 9) {
		// resultState.setState(ResultState.RESULT_STATE_FAIL);
		// resultState.setMessage("编号必须为9位数字或字母");
		// return "";
		// }
		/*
		 * 1.判断编号是否重复（整个系统判重）
		 */
		// boolean suc = trainingClassService.decideClassNum(vCommond);
		// if (suc) {
		// resultState.setState(ResultState.RESULT_STATE_FAIL);
		// resultState.setMessage("编号重复,请重新输入");
		// return "";
		// }
		/*
		 * 2.判断名称是否重复（不同承办部委下可以重复）
		 */
		// boolean succ = trainingClassService.decideClassName(vCommond);
		// if (succ) {
		// resultState.setState(ResultState.RESULT_STATE_FAIL);
		// resultState.setMessage("名称重复,请重新输入");
		// return "";
		// }

		if (token.isTokenValid(request, true)) {// 判断token
			// TrainingClass tclass= (TrainingClass) vCommond.toEntity();
			// 拼凑时间
			// if (PropertyUtil.objectNotEmpty(vCommond.getBeginDateStr())) {
			// tclass.setBeginDate(DateUtil.getDateByString(vCommond.getBeginDateStr(),
			// "yyyy-MM-dd"));
			// }
			// if (PropertyUtil.objectNotEmpty(vCommond.getEndDateStr())) {
			// tclass.setEndDate(DateUtil.getDateByString(vCommond.getEndDateStr(),
			// "yyyy-MM-dd"));
			// }
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			if (PropertyUtil.objectNotEmpty(vCommond.getBeginDateStr())) {
				String beginDateStr = vCommond.getBeginDateStr();
				vCommond.setBeginDate(sdf.parse(beginDateStr));
			}
			if (PropertyUtil.objectNotEmpty(vCommond.getEndDateStr())) {
				String endDateStr = vCommond.getEndDateStr();
				vCommond.setEndDate(sdf.parse(endDateStr));
				// 评估开始结束时间为结班时间的前1天后2天 add by LongJZ at 2016-3-30
				vCommond.setAssessStartTime(addDay(endDateStr, -1));
				vCommond.setAssessEndTime(addDay(endDateStr, 2));
			}
			if (PropertyUtil.objectNotEmpty(vCommond.getEnterBeginTimeStr())) {
				String enterBeginTimeStr = vCommond.getEnterBeginTimeStr();
				vCommond.setEnterBeginTime(sdf.parse(enterBeginTimeStr));
			}
			if (PropertyUtil.objectNotEmpty(vCommond.getEnterEndTimeStr())) {
				String enterEndTimeStr = vCommond.getEnterEndTimeStr();
				vCommond.setEnterEndTime(sdf.parse(enterEndTimeStr));
			}

			// 配置培训班的数据字典的属性
			// tclass=configureBaseData(tclass,vCommond);
			// 开班结班状态判断
			vCommond = decideOpenState(vCommond);
			/*
			 * vCommond.setTrainingHour(0.0);//学时
			 * vCommond.setClassUserNum(0);//班级人数
			 */
			vCommond.setPublishState(TrainingClass.IS_PUBLISH_N);
			vCommond.setActiveState(TrainingClass.IS_ACTIVE_Y);
			vCommond.setAuditState(TrainingClass.IS_N_AUDIT);// 未审核
			vCommond.setReportState(TrainingClass.IS_REPORT_N);// 未上报
			vCommond.setOpenState(TrainingClass.IS_OPENSTATE_N);// 只要是未发布，无论填写的开始结束时间是什么班级状态都是是未开班
			vCommond.setSignUpState(TrainingClass.IS_SIGNUP_N);// //只要是未发布，无论填写的报名开始结束时间是什么报名状态都是是未开始报名
			vCommond.setPerfectState(TrainingClass.PERFECTSTATE_N);// 信息未完善
			vCommond.setAllotDeptState(TrainingClass.IS_ALLOTDEPT_N);// 未分配指定单位状态
			vCommond.setBeoffStation(TrainingClass.FULL_TIME_YES);// 离岗状态默认脱产
			
			//vCommond.setLastOperateTime(new Date());
			vCommond.setLatestOperateDate(new Date());
			vCommond.setLastOperateTime(new Date());
			
			/*
			 * // 已结班 if (PropertyUtil.objectNotEmpty(vCommond.getEndDate()) &&
			 * compare_date(vCommond.getEndDate()) = 0)
			 * vCommond.setOpenState(TrainingClass.IS_ENDSTATE_Y); // 已开班 else
			 * if (PropertyUtil.objectNotEmpty(vCommond.getBeginDate()) &&
			 * compare_date(vCommond.getBeginDate()) <= 0)
			 * vCommond.setOpenState(TrainingClass.IS_OPENSTATE_Y); // 未开班 else
			 * if (PropertyUtil.objectNotEmpty(vCommond.getBeginDate()) &&
			 * compare_date(vCommond.getBeginDate()) > 0)
			 * vCommond.setOpenState(TrainingClass.IS_OPENSTATE_N); else
			 * vCommond.setOpenState(null);
			 */

			/*
			 * // 报名结束 if
			 * (PropertyUtil.objectNotEmpty(vCommond.getEnterEndTime()) &&
			 * compare_date(vCommond.getEnterEndTime()) = 0)
			 * vCommond.setSignUpState(TrainingClass.IS_SIGNUP_END); // 正在报名
			 * else if
			 * (PropertyUtil.objectNotEmpty(vCommond.getEnterBeginTime()) &&
			 * compare_date(vCommond.getEnterBeginTime()) <= 0)
			 * vCommond.setSignUpState(TrainingClass.IS_SIGNUP_BEGIN); // 报名未开始
			 * else if
			 * (PropertyUtil.objectNotEmpty(vCommond.getEnterBeginTime()) &&
			 * compare_date(vCommond.getEnterBeginTime()) > 0)
			 * vCommond.setSignUpState(TrainingClass.IS_SIGNUP_N); else
			 * vCommond.setSignUpState(null);
			 */

			// 拼凑名称
			// spellClassName(vCommond);
			// 班级编码
			/*
			 * String number=trainingClassService.getTrainingNum(vCommond);
			 * vCommond.setClassNum(number);
			 */
			//获得编号
			String classNum = trainingClassService.getTrainingClassNum();
//			classNum = (Integer.valueOf(classNum.split("X")[1]) + 1) + "";
			vCommond.setClassNum(classNum);

			// 执行添加培训班操作
			getService().save(vCommond);

			// 指定报名机构
			ClassSignUpDepartment csp;
			if (PropertyUtil.objectNotEmpty(vCommond.getSignUpDepartmentIds()) && PropertyUtil.objectNotEmpty(vCommond.getSignUpDepartmentIds()[0])) {
				String[] ids = vCommond.getSignUpDepartmentIds()[0].split(",");
				for (String i : ids) {
					csp = new ClassSignUpDepartment();
					csp.setActiveState(ClassSignUpDepartment.IS_ACTIVE_Y);
					csp.setCreateDate(new Date());
					Department d1 = new Department();
					d1.setDeptID(i);
					csp.setDept(d1);
					csp.setTrainingClass(vCommond.getTrainingClass());
					trainingClassService.saveEntity(csp);
					vCommond.getTrainingClass().getSignUpDepartment().add(csp);
				}
			} else {
				// 市委组织部不指定报名和非市委组织部指定报名
				if (d.getDeptID().equals(DeptConstants.SWZZB)) {
					csp = new ClassSignUpDepartment();
					csp.setActiveState(ClassSignUpDepartment.IS_ACTIVE_Y);
					csp.setCreateDate(new Date());
					csp.setDept(d);
					csp.setTrainingClass(vCommond.getTrainingClass());
					trainingClassService.saveEntity(csp);
					vCommond.getTrainingClass().getSignUpDepartment().add(csp);
				} else {
					DepartmentValidCommond commond = new DepartmentValidCommond();
					commond.setTreepath(d.getTreepath());
					List<Department> list = trainingClassService.findDedepartmentList(commond);
					for (Department l : list) {
						csp = new ClassSignUpDepartment();
						csp.setActiveState(ClassSignUpDepartment.IS_ACTIVE_Y);
						csp.setCreateDate(new Date());
						csp.setDept(l);
						csp.setTrainingClass(vCommond.getTrainingClass());
						trainingClassService.saveEntity(csp);
						vCommond.getTrainingClass().getSignUpDepartment().add(csp);
					}
				}
			}
			// 指定管理范围
			ClassScopeDepartment cspd;
			if (PropertyUtil.objectNotEmpty(vCommond.getScopeDepartmentIds()) && PropertyUtil.objectNotEmpty(vCommond.getScopeDepartmentIds()[0])) {
				String[] ids = vCommond.getScopeDepartmentIds()[0].split(",");
				for (String i : ids) {
					cspd = new ClassScopeDepartment();
					cspd.setActiveState(ClassScopeDepartment.IS_ACTIVE_Y);
					cspd.setCreateDate(new Date());
					Department d1 = new Department();
					d1.setDeptID(i);
					cspd.setDept(d1);
					cspd.setTrainingClass(vCommond.getTrainingClass());
					trainingClassService.saveEntity(cspd);
					vCommond.getTrainingClass().getScopeDepartment().add(cspd);
				}
			} else {
				cspd = new ClassScopeDepartment();
				cspd.setActiveState(ClassSignUpDepartment.IS_ACTIVE_Y);
				cspd.setCreateDate(new Date());
				cspd.setDept(d);
				cspd.setTrainingClass(vCommond.getTrainingClass());
				trainingClassService.saveEntity(cspd);
				vCommond.getTrainingClass().getScopeDepartment().add(cspd);
			}

			getService().update(vCommond);

			// if(vCommond.getTrainingClass().getClassType().getDataCode().equals(TrainingClass.TRAINING_TYPE_WSZTB)){
			// ThematicClassWrapBean bean=new ThematicClassWrapBean();
			// bean.setThematicClassId(vCommond.getClassId());// 专题班ID，同报名组件主键
			// bean.setClassName(vCommond.getClassName());// 班级名称
			// bean.setBeginDate(dateToXMLGregorianCalendar(vCommond.getBeginDate()));//
			// 日期
			// bean.setEndDate(dateToXMLGregorianCalendar(vCommond.getEndDate()));//
			// 日期
			// bean.setClassDescription(vCommond.getClassDescription());// 说明
			// bean.setIsLimit(0);// 是否限额
			// bean.setLimitNum(0);// 限额人数
			// bean.setApplyWay(0);// 报名方式
			// bean.setOrganizerId(Integer.valueOf(vCommond.getMinistrieID()));//
			// 主办单位ID
			// bean.setOrganizerName(vCommond.getMinistrieName());// 名称
			// bean.setUndertakeUnitId(Integer.valueOf(vCommond.getMinistrieID()));//ID
			// bean.setUndertakeUnitName(vCommond.getMinistrieName());// 名称
			// if(PropertyUtil.objectNotEmpty(vCommond.getJointMinistrieID())){
			// bean.setAssisstingUnitId(Integer.valueOf(vCommond.getJointMinistrieID()));//ID
			// bean.setAssisstingUnitName(vCommond.getJointMinistrieName());//
			// 名称
			// }
			// //默认为网络专题班集中考类型
			// bean.setClassType(1);// 类型
			// bean.setLinkman(vCommond.getContactPeople());// 联系人
			// bean.setContactWay(vCommond.getContactTel());// 联系方式
			// String
			// ii=vCommond.getTrainingHour().toString().substring(0,vCommond.getTrainingHour().toString().indexOf("."));
			// int i=Integer.valueOf(ii);
			// bean.setClassHour(i);// 班级学时
			// bean.setPublishState(vCommond.getPublishState());// 状态
			// bean.setOpenState(vCommond.getOpenState());// 状态
			// bean.setLatestOperateDate(dateToXMLGregorianCalendar(new
			// Date()));// 日期
			// bean.setCreateDate(dateToXMLGregorianCalendar(new Date())); //
			// 创建时间
			// bean.setActiveState(vCommond.getActiveState()); // 活动状态
			// bean.setClassCode(""); // 培训计划班级ID
			// bean.setLearningType(""); // 学习方式
			// bean.setClassRequiredHour(0);// 考核必修学时
			// bean.setClassTakedHour(0);// 考核选修学时
			// URL url = new URL(TrainingClass.WLZTB_WSDL_CLASS_URL);
			// ThematicClassWebServiceImplService service=new
			// ThematicClassWebServiceImplService(url);
			// thematicClassWebServiceImpl=service.getThematicClassWebServiceImplPort();
			// thematicClassWebServiceImpl.addThematicClass(bean);
			// }
			// //添加记录日志的逻辑 add by NingSS at 20150504
			// LogRecord logRecord = new LogRecord();
			// LogRecordParam paramChild = new LogRecordParam();
			// paramChild.setOpdataId(vCommond.getClassId());//操作主数据id
			// paramChild.setOpbefoData("");//操作前数据
			// paramChild.setOpafteData(vCommond.getTrainingClass().toString());//操作后数据
			// paramChild.setOpmodule("高校功能 - 院校维护培训班 - 新增");//操作模块
			// paramChild.setOpcontent("新增培训班");//操作说明
			// paramChild.setOptype(UniteConstants.ADD); //操作类型
			// logRecord.bulifLogParams(paramChild);
			// try {
			// LogThread logThread = new LogThread(paramChild);
			// Thread thread = new Thread(logThread);
			// thread.start();
			// } catch (Exception e) {
			// // TODO: handle exception
			// e.printStackTrace();
			// }
			// 添加二维码 add by NingSS at 2016-1-22
			// BuliderErWeiMa bewm= new BuliderErWeiMa();
			/*
			 * bewm.createQRCode( request.getScheme() + "://" +
			 * request.getServerName() + ":" +
			 * request.getServerPort()+""+request.getContextPath() +
			 * "/scan.do?method=scan&classId="+vCommond.getClassId()+"&userId="
			 * , "erweima/classErweima", "erweima/logo/logo.jpg",
			 * vCommond.getClassId(), request);
			 */
			// bewm.createQRCode( "http://www.baidu.com","erweima/classErweima",
			// "erweima/logo/logo.jpg", vCommond.getClassId(), request);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("添加成功");

			try {
				/**
				 * 添加提醒
				 * 
				 * @Date 2016-05-12
				 * @author RongSL
				 * @Params 提醒类型，培训班名称，承办部委名称，提醒分类
				 */
				// remindService.remindOperate(Remind.XZPXB,
				// vCommond.getClassName(), vCommond.getMinistrieName(),
				// vCommond.getClassId(), Remind.PXB);
			} catch (Exception e) {
				System.out.println("新增培训班提醒接口出错了！");
			}

		} else {
			resultState.setState(ResultState.RESULT_STATE_REPEAT_SUBMIT);// 重复提交
			resultState.setMessage("重复提交");
		}
		return "forward:" + getModulePath() + "/findList" + getRequestType(request);
	}

	/**
	 * 返回传入日期与当前日期的比较结果(精确到分),小于为-1,等于为0,大于为1
	 * 
	 * @param date
	 * @author LongJZ
	 * @return
	 */
	public int compare_date(Date date) {
		java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
		Date nDate = new Date();
		try {
			return df.parse(df.format(date)).compareTo(df.parse(df.format(nDate)));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return -2;
	}

	/**
	 * 当前管理范围下查询班级信息列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author GaoGQ
	 * @createDate 2014-12-10
	 */
	@RequestMapping(value = "/findTrainingClassListFinish")
	public String findTrainingClassListFinish(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}

		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(d.getDeptID()))
			qCommond.setSearchTrainingDeptId(d.getDeptID());
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchOpenState(TrainingClass.IS_ENDSTATE_Y);
		// 查询已发布的课程 by Max at 2015-04-03
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListFinish(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 查询培训班列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YanDong
	 * @createDate 2016-1-4
	 */
	@RequestMapping(value = "/findTrainingClassList")
	public String findTrainingClassList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		Role currentrole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		// 当前登录人部门ID
		qCommond.setSearchSponsorId(currentScope.getDeptID());

		// 当前登陆人角色 XXX 针对其他管理员只查询承办培训班,开放建班后可以去掉
		qCommond.setSearchRoleCode(currentrole.getCode());

		// 传递当前管理范围单位ID
		qCommond.setDeptId(currentScope.getDeptID());
		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		}
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassList(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 查询考核管理列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author RognSL
	 * @createDate 2017-2-22
	 */
	@RequestMapping(value = "/findExaminationList")
	public String findExaminationList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		Role currentrole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		// 当前登录人部门ID
		qCommond.setSearchSponsorId(currentScope.getDeptID());

		// 当前登陆人角色 XXX 针对其他管理员只查询承办培训班,开放建班后可以去掉
		qCommond.setSearchRoleCode(currentrole.getCode());

		// 考核列表只查询已结班班级
		qCommond.setSearchOpenState(TrainingClass.IS_ENDSTATE_Y);

		// 只查询已发布的培训班
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 传递当前管理范围单位ID
		qCommond.setDeptId(currentScope.getDeptID());
		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		}
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassList2(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 查询报名审核列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YanDong
	 * @createDate 2016-1-4
	 */
	@RequestMapping(value = "/findRegistrationClassList")
	public String findRegistrationClassList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);

		// 当前登录人
		qCommond.setSearchSponsorId(currentScope.getDeptID());
		// 传递当前管理范围单位ID
		qCommond.setDeptId(currentScope.getDeptID());

		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		qCommond.setSearchRoleCode(currentRole.getRoleCode());

		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		}
		// 设置点击来源：当有值的时候为报名审核，则只需查询主办单位下的班级
		// qCommond.setSearchFrameType("yes");

		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchClassTrainingType(DeptConstants.ZDBMJG);
		// 执行查询逻辑
		// List<TrainingClassQueryBean> resultList =
		// trainingClassService.findThematicClassList(qCommond);
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassList2(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 查询培训班列表(报名用)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YanDong
	 * @createDate 2016-1-4
	 */
	@RequestMapping(value = "/findTrainingClassListSignUp")
	public String findTrainingClassListSignUp(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// Department department = classUserDao.find(Department.class,
		// currentScope.getDeptID());
		// String levelCode=null;
		// int i=department.getTreepath().split("/").length;
		// if(PropertyUtil.objectNotEmpty(department.getAdminLevelCode())){
		// levelCode = department.getAdminLevelCode();
		// }else if(i==3){ //当管理范围为北京市下的无级别机构时默认为一级机构去处理
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_ONE);
		// }
		// //加入所属机构判断
		// qCommond.setTreePath(department.getTreepath());
		// if (TrainingClass.MECHANISM_TYPE_ONE.equals(levelCode)) {// 一级管理员
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_ONE);
		// } else if (TrainingClass.MECHANISM_TYPE_ONE.equals(levelCode)) {//
		// 二级管理员
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_TWO);
		// }
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		qCommond.setSearchRoleCode(currentRole.getRoleCode());
		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		}
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchSponsorId(currentScope.getDeptID());
		qCommond.setSearchClassTrainingType(DeptConstants.ZDBMJG);
		qCommond.setTreePath(currentScope.getTreepath());

		if (currentScope.getDeptID().equals(DeptConstants.SWZZB)) {
			qCommond.setUnitLevel(DeptConstants.SWZZB);
		} else {
			Department dept = classUserDao.find(Department.class, currentScope.getDeptID());
			qCommond.setUnitLevel(dept.getAdminLevelCode());
		}
		// 执行查询逻辑
		// List<TrainingClassQueryBean> resultList =
		// trainingClassService.findThematicClassListSignUp(qCommond);

		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListSignUp2(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * @课程评估查询
	 * @Name: findCourseAssessment
	 * @Author: RongSL
	 * @CreateDate: 2016-5-20
	 * @Return: List<TrainingClassQueryBean>
	 */
	@RequestMapping("findCourseAssessment")
	public String findCourseAssessment(@ModelAttribute("result") TrainingClassQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		ResultState rs = new ResultState();
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassId())) {
			List<TrainingClassQueryBean> list = trainingClassService.findCourseAssessment(queryCommond);
			queryCommond.setResultList(list);
			rs.setMessage("查询成功！");
			rs.setState(ResultState.RESULT_STATE_SUCCESS);
			BeanUtils.copyProperties(rs, resultState);
			return "";
		}
		rs.setMessage("缺少参数！");
		rs.setState(ResultState.RESULT_STATE_FAIL);
		BeanUtils.copyProperties(rs, resultState);
		return "";
	}

	/**
	 * 查询培训班列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YanDong
	 * @createDate 2016-1-4
	 */
	@RequestMapping(value = "/findTrainingClassAttendanceList")
	public String findTrainingClassAttendanceList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		String roleCode = currentRole.getCode();
		if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {// 部委管理员
			qCommond.setSearchMinistrieID(currentScope.getDeptID());
			// qCommond.setSearchMinistrieID("7498");
		} else if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {// 单位管理员
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			if (PropertyUtil.objectNotEmpty(d) && PropertyUtil.objectNotEmpty(d.getDeptID())) {
				qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			}
			// qCommond.setSearchTrainingApplyDeptId("7449");
			qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
			qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
			// qCommond.setSearchAuditState(TrainingClass.IS_AUDIT_Y);
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
			// 执行查询逻辑
			List<TrainingClassQueryBean> resultList = trainingClassService.queryTrainingClassList(qCommond);
			onAfterFindList(resultList, qCommond, request);
			// 存放结果
			qCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			return getModulePath() + "/list";
		}
		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		}
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// qCommond.setSearchOpenState(TrainingClass.IS_OPENSTATE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassList(qCommond);
		String ids[] = new String[resultList.size()];
		for (int i = 0; i < resultList.size(); i++) {
			ids[i] = resultList.get(i).getClassId();
		}
		qCommond.setSearchClassIds(ids);
		Map<String, Integer> ac = trainingClassService.getAttendanceChance(qCommond);
		for (TrainingClassQueryBean tcqb : resultList) {
			tcqb.setAttendance(ac.get(tcqb.getClassId()));
		}
		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 导出当前管理范围下班级信息列表
	 * 
	 * @param commond
	 * @param bindingResult
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author Xupp
	 * @createDate 2014-12-16
	 */
	@RequestMapping(value = "/exportTrainingClassList")
	public void exportTrainingClassList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		qCommond.setSearchTrainingDeptId(d.getDeptID());
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);

		onAfterFindList(resultList, qCommond, request);
		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		for (TrainingClassQueryBean qcub : resultList) {
			ExportClassBean eub = new ExportClassBean();
			eub.setBeginDate(sdf.format(qcub.getBeginDate()));
			eub.setClassName(qcub.getClassName());
			if (qcub.getClassUserNum() == -1) {
				eub.setClassUserNum("不限");
			} else {
				eub.setClassUserNum(qcub.getClassUserNum().toString());
			}
			eub.setClassNum(qcub.getClassNum());
			eub.setEndDate(sdf.format(qcub.getEndDate()));
			eub.setReportedNum(qcub.getReportedNum().longValue());
			eub.setTrainingHour(qcub.getTrainingHour());
			eub.setTrainingDeptName(qcub.getTrainingDeptName());
			classList.add(eub);
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("classListExportConfig");
		classSheet.setSheetName("班级信息列表");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "班级信息列表";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出工委班级列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月15日
	 */
	@RequestMapping(value = "/exportTrainingClassListForGW")
	public void exportTrainingClassListForGW(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if (attributeConverter != null) {
		// parameterValueConvert(qCommond, request, attributeConverter);
		// }
		// 查询已上报的数据
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);
		// List<TrainingClassQueryBean> resultList = trainingClassService
		// .findThematicClassListNoPage(qCommond);

		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		for (TrainingClassQueryBean qcub : resultList) {
			ExportClassBean eub = new ExportClassBean();
			eub.setBeginDate(sdf.format(qcub.getBeginDate()));
			eub.setClassName(qcub.getClassName());
			if (qcub.getClassUserNum() == -1) {
				eub.setClassUserNum("不限");
			} else {
				eub.setClassUserNum(qcub.getClassUserNum().toString());
			}
			eub.setClassNum(qcub.getClassNum());
			eub.setEndDate(sdf.format(qcub.getEndDate()));
			eub.setReportedNum(qcub.getReportedNum().longValue());
			eub.setTrainingHour(qcub.getTrainingHour());
			eub.setTrainingDeptName(qcub.getTrainingDeptName());
			classList.add(eub);
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("classListExportConfig");
		classSheet.setSheetName("班级信息列表");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "班级信息列表";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出中组部班级列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月15日
	 */
	@RequestMapping(value = "/exportTrainingClassListForZZB")
	public void exportTrainingClassListForZZB(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {

		//
		// if (attributeConverter != null) {
		// parameterValueConvert(qCommond, request, attributeConverter);
		// }
		// 查询已上报的数据
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);
		// 执行查询逻辑
		// List<TrainingClassQueryBean> resultList = trainingClassService
		// .findThematicClassListNoPage(qCommond);

		onAfterFindList(resultList, qCommond, request);
		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		for (TrainingClassQueryBean qcub : resultList) {
			ExportClassBean eub = new ExportClassBean();
			eub.setBeginDate(sdf.format(qcub.getBeginDate()));
			eub.setClassName(qcub.getClassName());
			if (qcub.getClassUserNum() == -1) {
				eub.setClassUserNum("不限");
			} else {
				eub.setClassUserNum(qcub.getClassUserNum().toString());
			}
			eub.setClassNum(qcub.getClassNum());
			eub.setEndDate(sdf.format(qcub.getEndDate()));
			eub.setReportedNum(qcub.getReportedNum().longValue());
			eub.setTrainingHour(qcub.getTrainingHour());
			eub.setTrainingDeptName(qcub.getTrainingDeptName());
			classList.add(eub);
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("classListExportConfig");
		classSheet.setSheetName("班级信息列表");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "班级信息列表";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出单位班级列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月15日
	 */
	@RequestMapping(value = "/exportTrainingClassListForDW")
	public void exportTrainingClassListForDW(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if (attributeConverter != null) {
		// parameterValueConvert(qCommond, request, attributeConverter);
		// }
		// 获得登陆者的管理范围
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(d) && PropertyUtil.objectNotEmpty(d.getDeptID())) {
			qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// queryCommond.setSearchTrainingApplyDeptId("8410");
			qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);// 活动班级
			qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);// 已发布班级
			// qCommond.setAuditState(TrainingClass.IS_AUDIT_Y);//审核通过班级
			// 执行查询逻辑
			List<TrainingClassQueryBean> resultList = trainingClassService.findTrainingClassListByDeptNoPage(qCommond);

			onAfterFindList(resultList, qCommond, request);
			List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			for (TrainingClassQueryBean qcub : resultList) {
				ExportClassBean eub = new ExportClassBean();
				eub.setBeginDate(sdf.format(qcub.getBeginDate()));
				eub.setClassName(qcub.getClassName());
				if (qcub.getClassUserNum() == -1) {
					eub.setClassUserNum("不限");
				} else {
					eub.setClassUserNum(qcub.getClassUserNum().toString());
				}
				eub.setClassNum(qcub.getClassNum());
				eub.setEndDate(sdf.format(qcub.getEndDate()));
				if (qcub.getCountUserNum() != null) {
					eub.setReportedNum(Long.parseLong(qcub.getDepUserNum().toString()));
				} else {
					eub.setReportedNum(0L);
				}

				eub.setTrainingHour(qcub.getTrainingHour());
				eub.setTrainingDeptName(qcub.getTrainingDeptName());
				classList.add(eub);
			}
			TrainingClassExport classExport = new TrainingClassExport();
			classExport.setExportClassBean(classList);
			TrainingClassSheet classSheet = new TrainingClassSheet();
			classSheet.setExportObject(classExport);
			classSheet.setExprotFormatName("classListExportConfig");
			classSheet.setSheetName("班级信息列表");

			Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
			ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
			String title = "班级信息列表";
			response.setContentType("application/msexcel;charset=ISO8859-1");
			response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
			OutputStream out = response.getOutputStream();
			excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		}
	}

	/**
	 * 导出当前管理范围下班级考勤情况列表
	 * 
	 * @param commond
	 * @param bindingResult
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2015-3-27
	 */
	@RequestMapping(value = "/exportTrainingClassAttendanceList")
	public void exportTrainingClassAttendanceList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		qCommond.setSearchTrainingDeptId(d.getDeptID());
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);

		String[] classIds = qCommond.getSearchClassIds()[0].split(",");
		List<String> ids = new ArrayList<String>();
		for (int i = 0; i < classIds.length; i++) {
			// if (i + 1 != classIds.length)
			ids.add(classIds[i]);
		}
		qCommond.setSearchClassIdList(ids);
		// 执行查询逻辑
		// 考勤导出班级列表的排序不同，加参数区分 by Max at 2015-04-07
		qCommond.setSearchType("attedence");
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);

		onAfterFindList(resultList, qCommond, request);
		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		for (TrainingClassQueryBean qcub : resultList) {
			ExportClassBean eub = new ExportClassBean();
			eub.setBeginDate(sdf.format(qcub.getBeginDate()));
			eub.setClassName(qcub.getClassName());
			if (qcub.getClassUserNum() == -1) {
				eub.setClassUserNum("不限");
			} else {
				eub.setClassUserNum(qcub.getClassUserNum().toString());
			}
			/*
			 * if (qcub.getReportedNum() <= 0) eub.setAttendanceRate("0%"); else
			 * { eub.setAttendanceRate((new BigDecimal(
			 * (qcub.getAttendanceNum().doubleValue() /
			 * qcub.getReportedNum().doubleValue() * 100) ).setScale(1,
			 * BigDecimal.ROUND_HALF_UP)).toString() + "%"); }
			 */
			eub.setAttendanceNum(qcub.getAllAttendance());
			eub.setAbsenceNum(qcub.getAbsenceAttendance());
			eub.setLeaveNum(qcub.getLeaveAttendance());
			eub.setNoAttendanceNum(qcub.getNoAttendance());
			eub.setAttendanceRate(qcub.getAttendanceRatePercent());

			eub.setClassNum(qcub.getClassNum());
			eub.setEndDate(sdf.format(qcub.getEndDate()));
			eub.setReportedNum(qcub.getReportedNum().longValue());
			eub.setTrainingHour(qcub.getTrainingHour());
			eub.setTrainingDeptName(qcub.getTrainingDeptName());
			classList.add(eub);
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("attendanceExportConfig");
		classSheet.setSheetName("培训班总体考勤情况");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "培训班总体考勤情况";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出工委班级考勤情况列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @date 2015年3月26日
	 */
	@RequestMapping(value = "/exportTrainingClassAttendanceListForGW")
	public void exportTrainingClassAttendanceListForGW(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if (attributeConverter != null) {
		// parameterValueConvert(qCommond, request, attributeConverter);
		// }
		// 查询已上报的数据
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);

		/*
		 * String[] classIds = qCommond.getSearchClassIds()[0].split(",");
		 * String ids = "'"; for (int i = 0; i < classIds.length; i++) { if (i +
		 * 1 != classIds.length) ids += classIds[i] + "','"; else ids +=
		 * classIds[i] + "'"; } qCommond.setSearchClassId(ids);
		 */
		String[] classIds = qCommond.getSearchClassIds()[0].split(",");
		List<String> ids = new ArrayList<String>();
		for (int i = 0; i < classIds.length; i++) {
			// if (i + 1 != classIds.length)
			ids.add(classIds[i]);
		}
		qCommond.setSearchClassIdList(ids);
		// 执行查询逻辑
		// 考勤导出班级列表的排序不同，加参数区分 by Max at 2015-04-07
		qCommond.setSearchType("attedence");
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);

		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		for (TrainingClassQueryBean qcub : resultList) {
			ExportClassBean eub = new ExportClassBean();
			eub.setBeginDate(sdf.format(qcub.getBeginDate()));
			eub.setClassName(qcub.getClassName());
			if (qcub.getClassUserNum() == -1) {
				eub.setClassUserNum("不限");
			} else {
				eub.setClassUserNum(qcub.getClassUserNum().toString());
			}
			eub.setAttendanceNum(qcub.getAllAttendance());
			eub.setAbsenceNum(qcub.getAbsenceAttendance());
			eub.setLeaveNum(qcub.getLeaveAttendance());
			eub.setNoAttendanceNum(qcub.getNoAttendance());
			eub.setAttendanceRate(qcub.getAttendanceRatePercent());
			eub.setClassNum(qcub.getClassNum());
			eub.setEndDate(sdf.format(qcub.getEndDate()));
			eub.setReportedNum(qcub.getReportedNum().longValue());
			eub.setTrainingHour(qcub.getTrainingHour());
			eub.setTrainingDeptName(qcub.getTrainingDeptName());
			classList.add(eub);
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("attendanceExportConfig");
		classSheet.setSheetName("培训班总体考勤情况");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "培训班总体考勤情况";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出中组部班级考勤情况列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @date 2015年3月27日
	 */
	@RequestMapping(value = "/exportTrainingClassAttendanceListForZZB")
	public void exportTrainingClassAttendanceListForZZB(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {

		// 查询已上报的数据
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);

		String[] classIds = qCommond.getSearchClassIds()[0].split(",");
		List<String> ids = new ArrayList<String>();
		for (int i = 0; i < classIds.length; i++) {
			// if (i + 1 != classIds.length)
			ids.add(classIds[i]);
		}
		qCommond.setSearchClassIdList(ids);
		// 执行查询逻辑
		// 考勤导出班级列表的排序不同，加参数区分 by Max at 2015-04-07
		qCommond.setSearchType("attedence");
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListNoPage(qCommond);

		onAfterFindList(resultList, qCommond, request);
		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		for (TrainingClassQueryBean qcub : resultList) {
			ExportClassBean eub = new ExportClassBean();
			eub.setBeginDate(sdf.format(qcub.getBeginDate()));
			eub.setClassName(qcub.getClassName());
			if (qcub.getClassUserNum() == -1) {
				eub.setClassUserNum("不限");
			} else {
				eub.setClassUserNum(qcub.getClassUserNum().toString());
			}
			eub.setAttendanceNum(qcub.getAllAttendance());
			eub.setAbsenceNum(qcub.getAbsenceAttendance());
			eub.setLeaveNum(qcub.getLeaveAttendance());
			eub.setNoAttendanceNum(qcub.getNoAttendance());
			eub.setAttendanceRate(qcub.getAttendanceRatePercent());
			eub.setClassNum(qcub.getClassNum());
			eub.setEndDate(sdf.format(qcub.getEndDate()));
			eub.setReportedNum(qcub.getReportedNum().longValue());
			eub.setTrainingHour(qcub.getTrainingHour());
			eub.setTrainingDeptName(qcub.getTrainingDeptName());
			classList.add(eub);
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("attendanceExportConfig");
		classSheet.setSheetName("培训班总体考勤情况");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "培训班总体考勤情况";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 导出单位班级考勤情况列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @date 2015年3月27日
	 */
	@RequestMapping(value = "/exportTrainingClassAttendanceListForDW")
	public void exportTrainingClassAttendanceListForDW(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if (attributeConverter != null) {
		// parameterValueConvert(qCommond, request, attributeConverter);
		// }
		// 获得登陆者的管理范围
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(d) && PropertyUtil.objectNotEmpty(d.getDeptID())) {
			qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// queryCommond.setSearchTrainingApplyDeptId("8410");
			qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);// 活动班级
			qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);// 已发布班级
			// qCommond.setAuditState(TrainingClass.IS_AUDIT_Y);//审核通过班级
			String[] classIds = { "" };
			if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassIds())) {
				classIds = qCommond.getSearchClassIds()[0].split(",");
				List<String> ids = new ArrayList<String>();
				for (int i = 0; i < classIds.length; i++) {
					// if (i + 1 != classIds.length)
					ids.add(classIds[i]);
				}
				qCommond.setSearchClassIdList(ids);
			}
			// 执行查询逻辑
			// 考勤导出班级列表的排序不同，加参数区分 by Max at 2015-04-07
			qCommond.setSearchType("attedence");
			List<TrainingClassQueryBean> resultList = trainingClassService.findTrainingClassListByDeptNoPage(qCommond);

			onAfterFindList(resultList, qCommond, request);
			List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			for (TrainingClassQueryBean qcub : resultList) {
				ExportClassBean eub = new ExportClassBean();
				eub.setBeginDate(sdf.format(qcub.getBeginDate()));
				eub.setClassName(qcub.getClassName());
				if (qcub.getClassUserNum() == -1) {
					eub.setClassUserNum("不限");
				} else {
					eub.setClassUserNum(qcub.getClassUserNum().toString());
				}
				eub.setClassNum(qcub.getClassNum());
				eub.setEndDate(sdf.format(qcub.getEndDate()));
				if (qcub.getCountUserNum() != null) {
					eub.setReportedNum(Long.parseLong(qcub.getDepUserNum().toString()));
				} else {
					eub.setReportedNum(0L);
				}
				eub.setAttendanceNum(qcub.getAllAttendance());
				eub.setAbsenceNum(qcub.getAbsenceAttendance());
				eub.setLeaveNum(qcub.getLeaveAttendance());
				eub.setNoAttendanceNum(qcub.getNoAttendance());
				eub.setAttendanceRate(qcub.getAttendanceRatePercent());
				eub.setTrainingHour(qcub.getTrainingHour());
				eub.setTrainingDeptName(qcub.getTrainingDeptName());
				classList.add(eub);
			}
			TrainingClassExport classExport = new TrainingClassExport();
			classExport.setExportClassBean(classList);
			TrainingClassSheet classSheet = new TrainingClassSheet();
			classSheet.setExportObject(classExport);
			classSheet.setExprotFormatName("attendanceExportConfig");
			classSheet.setSheetName("培训班总体考勤情况");

			Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
			ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
			String title = "培训班总体考勤情况";
			response.setContentType("application/msexcel;charset=ISO8859-1");
			response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
			OutputStream out = response.getOutputStream();
			excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		}
	}

	/**
	 * 查询培训班(中组部）
	 * 
	 * @param commond
	 * @author YanDong
	 */
	@RequestMapping(value = "/findTraining")
	public String findTraining(@ModelAttribute("result") @Valid TrainingClassValidCommond vCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		String classId = vCommond.getClassId();
		if (PropertyUtil.objectNotEmpty(classId)) {
			TrainingClassValidCommond co = this.getService().find(classId);
			BeanUtils.copyProperties(co, vCommond);

			// 读取承办部门&&指定机构
			String names = "";
			String ids = "";
			String namess1[] = new String[co.getTrainingClass().getScopeDepartment().size()];
			String namess2[] = new String[co.getTrainingClass().getSignUpDepartment().size()];
			String namess3[] = new String[co.getTrainingClass().getScopeDepartment().size()];
			String namess4[] = new String[co.getTrainingClass().getSignUpDepartment().size()];
			Iterator<?> ite = co.getTrainingClass().getSignUpDepartment().iterator();
			if (co.getSignupOr() == TrainingClass.SIGNUPOr_Y) {
				namess1 = new String[] {};
				namess3 = new String[] {};
			} else {
				while (ite.hasNext()) {
					ClassSignUpDepartment c = (ClassSignUpDepartment) ite.next();
					names += c.getDept().getDeptName() + ",";
					ids += c.getDept().getDeptID() + ",";
				}
				namess1 = names.split(",");
				namess3 = ids.split(",");
				vCommond.setSignUpDepartmentIds(namess3);
				vCommond.setSignUpDepartmentNames(namess1[0].equals("北京市") ? new String[] { "所有单位" } : namess1);
			}
			names = "";
			ids = "";
			ite = co.getTrainingClass().getScopeDepartment().iterator();
			while (ite.hasNext()) {
				ClassScopeDepartment c = (ClassScopeDepartment) ite.next();
				names += c.getDept().getDeptName() + ",";
				ids += c.getDept().getDeptID() + ",";
			}
			namess2 = names.split(",");
			namess4 = ids.split(",");

			vCommond.setScopeDepartmentIds(namess4);
			vCommond.setScopeDepartmentNames(namess2);
			if (!PropertyUtil.objectNotEmpty(vCommond.getBeoffStation())) {
				vCommond.setBeoffStation("tc");
			}
			// vCommond.setDeptCode(role.getRoleCode());
			// vCommond.setManagerDepartId(deptId);
			// 补全班级信息
			// vCommond=trainingClassService.swapClassInfo(vCommond);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("培训班ID为空");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}
		return "";
	}

	/**
	 * 查询培训班(中组部）
	 * 
	 * @param commond
	 * @author YanDong
	 */
	@RequestMapping(value = "/findTrainingByPxarchives")
	public String findTrainingByPxarchives(
			@ModelAttribute("result") @Valid TrainingClassValidCommond vCommond,
			HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute("resultState") ResultState resultState)
			throws Exception {
		if (PropertyUtil.objectNotEmpty(vCommond.getClassId())) {
			TrainingClassValidCommond co = this.trainingClassService.findTrainingPxarchives(vCommond);
			BeanUtils.copyProperties(co, vCommond);
			// 读取承办部门&&指定机构
			String names = "";
			String ids = "";
			String namess1[] = new String[vCommond.getTrainingClass()
					.getScopeDepartment().size()];
			String namess2[] = new String[vCommond.getTrainingClass()
					.getSignUpDepartment().size()];
			String namess3[] = new String[vCommond.getTrainingClass()
					.getScopeDepartment().size()];
			String namess4[] = new String[vCommond.getTrainingClass()
					.getSignUpDepartment().size()];
			Iterator<?> ite = vCommond.getTrainingClass().getSignUpDepartment()
					.iterator();
			while (ite.hasNext()) {
				ClassSignUpDepartment c = (ClassSignUpDepartment) ite.next();
				names += c.getDept().getDeptName() + ",";
				ids += c.getDept().getDeptID() + ",";
			}
			namess1 = names.split(",");
			namess3 = ids.split(",");

			names = "";
			ids = "";
			ite = vCommond.getTrainingClass().getScopeDepartment().iterator();
			while (ite.hasNext()) {
				ClassScopeDepartment c = (ClassScopeDepartment) ite.next();
				names += c.getDept().getDeptName() + ",";
				ids += c.getDept().getDeptID() + ",";
			}
			namess2 = names.split(",");
			namess4 = ids.split(",");

			vCommond.setSignUpDepartmentIds(namess3);
			vCommond.setSignUpDepartmentNames(namess1[0].equals("北京市") ? new String[] { "所有单位" }
					: namess1);
			vCommond.setScopeDepartmentIds(namess4);
			vCommond.setScopeDepartmentNames(namess2);
			Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
			vCommond.setClassLevel(currentRole.getCode());
			
			String className = vCommond.getTrainingClass().getClassName();
			vCommond.getTrainingClass().setClassName(className.substring(5));
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("培训班ID为空");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}
		return "";
	}
	
	/**
	 * 修改培训班信息
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author Max
	 * @createDate 2014-12-10
	 */
	@RequestMapping(value = "/updateTraingClass")
	public String updateTraingClass(@ModelAttribute("result") TrainingClassValidCommond vCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if(token.isTokenValid(request, true)){//判断token
		// 以下几句代码用于部委完善信息时消息提醒
		/**
		 * 
		 * for (String s : vCommond.getSignUpDepartmentIds()) {
		 * if("".equals(s)){ vCommond.setSignupOr(TrainingClass.SIGNUPOr_Y);
		 * break; }else { vCommond.setSignupOr(TrainingClass.SIGNUPOr_N); break;
		 * } }
		 * 
		 */
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		if (PropertyUtil.objectNotEmpty(currentRole)) {
			String roleCode = currentRole.getCode();
			if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {// 部委管理员
				vCommond.setRoleCode(roleCode);
			}
		}
		/*
		 * 1.判断编号是否重复（整个系统判重）
		 */
		boolean suc = trainingClassService.decideClassNum(vCommond);
		if (suc) {
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			resultState.setMessage("编号重复,请重新输入");
			return "";
		}
		Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		vCommond.setCurrenDepartmentId(d.getDeptID());
		for (String s : vCommond.getSignUpDepartmentIds()) {
			if ("".equals(s)) {
				vCommond.setSignupOr(TrainingClass.SIGNUPOr_Y);
				break;
			} else {
				vCommond.setSignupOr(TrainingClass.SIGNUPOr_N);
				break;
			}
		}
		if (trainingClassService.updateTraingClass(vCommond).equals("hava")) {
			resultState.setMessage("名称重复");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		} else {
			// 添加提醒功能
			/*
			 * try { if
			 * (PropertyUtil.objectNotEmpty(vCommond.getUpdateInformation()))
			 * {// 有更新的字段
			 * 
			 * // 更新提醒状态
			 * remindUserLinkService.updateSendRemindState(vCommond.getClassId()
			 * );
			 * 
			 * ClassPlanApplyQueryCommond Commond = new
			 * ClassPlanApplyQueryCommond();
			 * Commond.setSearchClassId(vCommond.getClassId());
			 * List<ClassPlanApplyQueryBean> cp =
			 * classPlanApplyService.findClassPlanApplyList(Commond); // 向中组部推送
			 * remindService.remindOperate(Remind.WSPXB,
			 * vCommond.getClassName(), RoleConstants.ROLE_ZZB_NAME,
			 * vCommond.getUpdateInformation(), vCommond.getClassId(),
			 * Remind.PXB); // 地方推送 for (ClassPlanApplyQueryBean c : cp) { if
			 * (c.getAsignCount() != 0 && !c.getDeptCode().equals("合计")) {
			 * remindService.remindOperate(Remind.WSPXB,
			 * vCommond.getClassName(), RoleConstants.ROLE_DF_NAME,
			 * vCommond.getUpdateInformation(), c.getDeptCode(),
			 * vCommond.getClassId(), Remind.PXB); } } } } catch (Exception e) {
			 * System.out.println("完善培训班提醒接口出错了！"); }
			 */
			resultState.setMessage("修改成功");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		}

		/*
		 * }else { resultState.setMessage("重复提交");
		 * resultState.setState(ResultState.RESULT_STATE_REPEAT_SUBMIT); }
		 */
		return "";
	}

	/**
	 * 班级状态修改
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author Max
	 * @date 2014-12-11
	 */
	@RequestMapping(value = "/batchUpdateClassState")
	public String batchUpdateTrainingClassPart(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if(token.isTokenValid(request, true)){//判断token
		TrainingClassPartFieldUpdateBean trainingClassPartFieldUpdateBean = new TrainingClassPartFieldUpdateBean();
		TrainingClassValidCommond trainingClassValidCommond = new TrainingClassValidCommond();
		trainingClassPartFieldUpdateBean.setiQueryCommond(queryCommond);
		String submintType = queryCommond.getSubmintType();
		// 启用 ==> 作废
		if (TrainingConstants.IS_ACTIVE_Y_TO_N.equals(submintType)) {
			trainingClassValidCommond.setActiveState(TrainingConstants.IS_ACTIVE_N);
		} /*
			 * else if(TrainingConstants.IS_REPORT_Y.equals(submintType)){ //上报
			 * if (trainingClassService.getCourseNum(queryCommond)) {
			 * trainingClassValidCommond.setReportState(TrainingClass.
			 * IS_REPORT_Y); } else { resultState.setMessage("班级没有配置课程，不能提交审核");
			 * resultState.setState(ResultState.RESULT_STATE_FAIL); return ""; }
			 * }
			 */
		else if (TrainingConstants.IS_PUBLISH_Y_TO_N.equals(submintType)) {
			/*
			 * if (trainingClassService.getStudentNum(queryCommond)) {
			 * trainingClassValidCommond
			 * .setPublishState(TrainingClass.IS_PUBLISH_N); } else {
			 * resultState.setMessage("已有学员报名,请删除学员后再进行撤销发布！");
			 * resultState.setState(ResultState.RESULT_STATE_FAIL); return ""; }
			 */
			trainingClassValidCommond.setPublishState(TrainingClass.IS_PUBLISH_N);
		} else if (TrainingConstants.IS_PUBLISH_N_TO_Y.equals(submintType)) {
			// if (!trainingClassService.getCourseNum(queryCommond)) {
			// resultState.setMessage("请先配置课程再进行发布操作！");
			// resultState.setState(ResultState.RESULT_STATE_FAIL);
			// return "";
			// }
			trainingClassValidCommond.setPublishState(TrainingClass.IS_PUBLISH_Y);
		}
		trainingClassValidCommond.setLatestOperateDate(new Date());
		trainingClassValidCommond.setLastOperateTime(new Date());
		trainingClassPartFieldUpdateBean.setiCommond(trainingClassValidCommond);
		trainingClassService.updateTrainingClassState(trainingClassPartFieldUpdateBean);
		resultState.setMessage("操作成功");
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);

		// 判断是否发送提醒
		if (PropertyUtil.objectNotEmpty(queryCommond.getSendState()) && queryCommond.getSendState() == 1) {
			/**
			 * 添加提醒
			 * 
			 * @Date 2016-05-12
			 * @author RongSL
			 * @Params 提醒类型，培训班名称，承办部委名称，提醒分类
			 */
			// TODO
			@SuppressWarnings("unchecked")
			List<TrainingClassValidCommond> list = (List<TrainingClassValidCommond>) trainingClassService.findList(queryCommond);
			DateUtil d = new DateUtil();
			if (PropertyUtil.objectNotEmpty(list)) {
				for (TrainingClassValidCommond l : list) {
					Department dep = (Department) request.getSession().getAttribute("currentScope");
					ClassPlanApplyQueryCommond Commond = new ClassPlanApplyQueryCommond();
					Commond.setSearchClassId(l.getClassId());
					List<ClassPlanApplyQueryBean> cp = classPlanApplyService.findClassPlanApplyList(Commond);
					// try {
					// // 发布
					// if
					// (TrainingConstants.IS_PUBLISH_N_TO_Y.equals(queryCommond.getSubmintType()))
					// {
					// // 向中组部推送
					// remindService.remindOperate(Remind.FBPXB,
					// l.getClassName(), RoleConstants.ROLE_ZZB_NAME,
					// dep.getDeptName(),
					// d.StringDateToStr(l.getEnterBeginTimeStr()),
					// d.StringDateToStr(l.getEnterEndTimeStr()),
					// l.getClassId(), Remind.PXB);
					// // 地方推送
					// for (ClassPlanApplyQueryBean c : cp) {
					// if (c.getAsignCount() != 0 &&
					// !c.getDeptCode().equals("合计")) {
					// remindService.remindOperate(Remind.FBPXB,
					// l.getClassName(), RoleConstants.ROLE_DF_NAME,
					// dep.getDeptName(), c.getDeptCode(),
					// d.StringDateToStr(l.getEnterBeginTimeStr()),
					// d.StringDateToStr(l.getEnterEndTimeStr()),
					// l.getClassId(), Remind.PXB);
					// }
					// }
					// } else if
					// (TrainingConstants.IS_PUBLISH_Y_TO_N.equals(submintType))
					// { // 取消发布
					// remindService.remindOperate(Remind.CXFBPXB,
					// l.getClassName(), RoleConstants.ROLE_ZZB_NAME,
					// dep.getDeptName(), queryCommond.getRevokeCause(),
					// l.getClassId(), Remind.PXB);
					// // 地方推送
					// for (ClassPlanApplyQueryBean c : cp) {
					// if (c.getAsignCount() != 0 &&
					// !c.getDeptCode().equals("合计")) {
					// remindService.remindOperate(Remind.CXFBPXB,
					// l.getClassName(), RoleConstants.ROLE_DF_NAME,
					// dep.getDeptName(), c.getDeptCode(),
					// queryCommond.getRevokeCause(),
					// l.getClassId(), Remind.PXB);
					// }
					// }
					// }
					// } catch (Exception e) {
					// System.out.println("发布或取消发布培训班提醒接口出错了！");
					// }
				}
			}
		}
		return "";
	}

	/**
	 * 当前管理范围下查询班级信息列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author Max
	 * @createDate 2014-12-10
	 */
	@RequestMapping(value = "/findClassListForGW")
	public String findClassListForGW(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		// 查询已上报的数据
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassList(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 当前管理范围下查询班级信息列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author Max
	 * @createDate 2014-12-10
	 */
	@RequestMapping(value = "/findClassListForGWFinish")
	public String findClassListForGWFinish(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		// 查询已上报的数据
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 设置结班状态
		qCommond.setSearchOpenState(TrainingClass.IS_ENDSTATE_Y);
		// 查询已发布的课程 by Max at 2015-04-03
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListFinish(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 审核操作
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author Max
	 * @date 2013-12-25
	 */
	@RequestMapping(value = "/updateClassAuditState")
	public String updateClassAuditState(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if(token.isTokenValid(request, true)){//判断token

		com.eorchis.module.user.domain.User user = (com.eorchis.module.user.domain.User) request.getSession().getAttribute(SessionConstant.USER_INFO);
		queryCommond.setAuditUserId(user.getUserId());
		trainingClassService.updateClassAuditState(queryCommond);
		resultState.setMessage("操作成功");
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		// }else {
		// resultState.setMessage("重复提交");
		// resultState.setState(ResultState.RESULT_STATE_REPEAT_SUBMIT);
		// }
		return "";
	}

	/**
	 * 工委修改班级信息
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author Max
	 * @createDate 2014-12-15
	 */
	@RequestMapping(value = "/updateClassForGW")
	public String updateClassForGW(@ModelAttribute("result") TrainingClassValidCommond vCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (token.isTokenValid(request, true)) {// 判断token
			trainingClassService.updateClassForGW(vCommond);
			resultState.setMessage("修改成功");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("重复提交");
			resultState.setState(ResultState.RESULT_STATE_REPEAT_SUBMIT);
		}
		return "";
	}

	/**
	 * 用于排序的方法
	 * 
	 * @param queryCommond
	 * @param request
	 * @param attributeConverter
	 */
	@SuppressWarnings("unchecked")
	private void parameterValueConvert(TrainingClassQueryCommond queryCommond, HttpServletRequest request, List<IQueryCommondAttributeConverter> attributeConverter) {
		for (IQueryCommondAttributeConverter queryCommondAttributeConverter : attributeConverter) {
			queryCommondAttributeConverter.convert(queryCommond, request.getParameterMap());
		}
	}

	/**
	 * 配置数据字典的数据
	 * 
	 * @param tclass
	 * @return
	 * @author Max
	 * @date 2013-12-13
	 */
	private TrainingClass configureBaseData(TrainingClass tclass, TrainingClassValidCommond vCommond) {

		if (PropertyUtil.objectNotEmpty(vCommond.getClassType())) {
			BaseData data = new BaseData();
			data.setDataCode(vCommond.getClassType());
			tclass.setClassType(data);
		}
		if (PropertyUtil.objectNotEmpty(vCommond.getApplyWay())) {
			BaseData data = new BaseData();
			data.setDataCode(vCommond.getApplyWay());
			tclass.setApplyWay(data);
		}
		if (PropertyUtil.objectNotEmpty(vCommond.getClassnamePeriod())) {
			BaseData data = new BaseData();
			data.setDataCode(vCommond.getClassnamePeriod());
			tclass.setClassnamePeriod(data);
		}
		return tclass;
	}

	/**
	 * 根据管理范围查询组织机构树
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author Max
	 * @createDate 2013-5-20
	 */
	@RequestMapping(value = "/findDepartmentTree")
	public @ResponseBody List<JsonTreeBean> findDepartmentTree(DepartmentTreeCommond commond, HttpServletRequest request) throws Exception {
		List<JsonTreeBean> result = new ArrayList<JsonTreeBean>();
		Department department;
		if(PropertyUtil.objectNotEmpty(commond.getSearchProjectID())){
			department = classUserDao.find(Department.class, commond.getSearchProjectID());
		}else{
			// 取出当前管理范围
			department = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		}
		if (!PropertyUtil.objectNotEmpty(commond.getNode()) || commond.getNode().equals(JsonTreeBean.ROOT_NODE_PARENT_ID)) {
			commond.setNode(department.getDeptID());
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			BeanUtils.copyProperties(commond, condition);
			condition.setFindLeapNode(true);
			List<JsonTreeBean> list = departmentTreeService.doProcess(condition);
			JsonTreeBean rootBean = new JsonTreeBean();
			rootBean.setText(department.getDeptName());
			rootBean.setId(department.getDeptID());
			rootBean.setChildren(list);
			rootBean.setLeaf(false);
			rootBean.setState("close");
			rootBean.setExpandable(true);
			result.add(rootBean);
		} else {
			commond.setNode(commond.getNode().substring(0, commond.getNode().indexOf(",") == -1 ? commond.getNode().length() : commond.getNode().indexOf(",")));
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			BeanUtils.copyProperties(commond, condition);
			condition.setFindLeapNode(true);
			result = departmentTreeService.doProcess(condition);
		}
		return result;
	}

	/**
	 * 根据管理范围查询组织机构树
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author Max
	 * @createDate 2013-5-20
	 */
	@RequestMapping(value = "/findDepartmentTreeAudit")
	public @ResponseBody List<JsonTreeBean> findDepartmentTreeAudit(DepartmentTreeCommond commond, HttpServletRequest request) throws Exception {
		List<JsonTreeBean> result = new ArrayList<JsonTreeBean>();
		// 取出当前管理范围
		// Department department = (Department)
		// request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		String depId = request.getParameter("depId");
		Department department = classUserDao.find(Department.class, depId);
		if (!PropertyUtil.objectNotEmpty(commond.getNode()) || commond.getNode().equals(JsonTreeBean.ROOT_NODE_PARENT_ID)) {
			commond.setNode(department.getDeptID());
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			BeanUtils.copyProperties(commond, condition);
			condition.setFindLeapNode(true);
			List<JsonTreeBean> list = departmentTreeService.doProcess(condition);
			JsonTreeBean rootBean = new JsonTreeBean();
			rootBean.setText(department.getDeptName());
			rootBean.setId(department.getDeptID());
			rootBean.setChildren(list);
			rootBean.setLeaf(false);
			rootBean.setState("close");
			rootBean.setExpandable(true);
			result.add(rootBean);
		} else {
			commond.setNode(commond.getNode().substring(0, commond.getNode().indexOf(",") == -1 ? commond.getNode().length() : commond.getNode().indexOf(",")));
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			BeanUtils.copyProperties(commond, condition);
			condition.setFindLeapNode(true);
			result = departmentTreeService.doProcess(condition);
		}
		return result;
	}

	// /**
	// * 合办单位左侧树
	// * @param commond
	// * @return
	// * @throws Exception
	// * @author Max
	// * @createDate 2012-12-16
	// */
	// @RequestMapping(value = "/findDepartmentTrees")
	// public
	// @ResponseBody List<JsonTreeBean>
	// findDepartmentTree(@ModelAttribute("resultList") ClassUserQueryCommond
	// commond,HttpServletRequest request,HttpServletResponse
	// response,ResultState resultState) throws Exception {
	// Integer depID = -2;
	// if( commond.getId() ==null || "".equals(commond.getId())){
	// commond.setId(depID.toString());
	// }
	// DepartmentCondition paramDepartmentCondition = new DepartmentCondition();
	// paramDepartmentCondition.setSearchParentID(commond.getId());
	// paramDepartmentCondition.setRows(-1);
	// paramDepartmentCondition.setStart(-1);
	// paramDepartmentCondition.setSearchActiveState(Department.IS_ACTIVE_Y);
	// //默认活动
	// List<Department> list =
	// iDepartmentService.findList(paramDepartmentCondition);
	// List<JsonTreeBean> result = buildJson(list);
	// commond.setResultList(result);
	// resultState.setState(ResultState.RESULT_STATE_SUCCESS);
	// return result;
	// }
	/**
	 * Description:构建Json <br>
	 * 
	 * @param list
	 * @return
	 * @author Max
	 * @throws Exception
	 * @createDate 2013-12-16
	 */
	private List<JsonTreeBean> buildJson(List<Department> list) throws Exception {
		List<JsonTreeBean> result = new ArrayList<JsonTreeBean>();
		if (list != null) {
			for (Department dept : list) {
				JsonTreeBean bean = new JsonTreeBean();
				bean.setId(dept.getDeptID());
				bean.setText(dept.getDeptName());
				bean.setExpandable(true);
				bean.setLeaf(false);
				result.add(bean);
			}
		}
		return result;
	}

	public TrainingClassValidCommond decideOpenState(TrainingClassValidCommond vCommond) throws Exception {
		// 根据开班时间判断开班状态 by Max at 2013-12-17
		if (vCommond.getBeginDate() != null && vCommond.getEndDate() != null) {
			Date beginDate = vCommond.getBeginDate();
			Date endDate = vCommond.getEndDate();
			Date nowDate = new Date();
			java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm");
			java.util.Calendar c1 = java.util.Calendar.getInstance();
			java.util.Calendar c2 = java.util.Calendar.getInstance();
			java.util.Calendar c3 = java.util.Calendar.getInstance();
			c1.setTime(df.parse(df.format(beginDate)));
			c2.setTime(df.parse(df.format(endDate)));
			c3.setTime(df.parse(df.format(nowDate)));
			int result1 = c1.compareTo(c3);
			int result2 = c2.compareTo(c3);
			if (result1 == 0) {
				// 开班
				vCommond.setOpenState(TrainingClass.IS_OPENSTATE_Y);
				// vCommond.setEndState(TrainingClass.IS_ENDSTATE_N);
			} else if (result1 < 0) {
				if (result2 < 0) {
					// 结班
					vCommond.setOpenState(TrainingClass.IS_ENDSTATE_Y);
					// vCommond.setOpenState(TrainingClass.IS_OPENSTATE_Y);
				} else {
					// 开班
					vCommond.setOpenState(TrainingClass.IS_OPENSTATE_Y);
					// vCommond.setEndState(TrainingClass.IS_ENDSTATE_N);
				}
			} else {
				// 未开班
				vCommond.setOpenState(TrainingClass.IS_OPENSTATE_N);
				// vCommond.setEndState(TrainingClass.IS_ENDSTATE_N);
			}
		}
		return vCommond;
	}

	/**
	 * 拼凑班级名称
	 * 
	 * @param commond
	 * @return
	 * @author Max
	 */
	private String spellClassName(TrainingClassValidCommond vCommond) {
		String classMainName = "";
		classMainName = vCommond.getClassnameYear() + "年" + vCommond.getClassName();
		vCommond.setClassMainName(classMainName);
		return classMainName;
	}

	/**
	 * 获取班级信息和班级审核信息
	 * 
	 * @param commond
	 * @param bindingResult
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author Max
	 * @createDate 2013-12-12
	 */
	@RequestMapping(value = "/findTrainingAndAuditInfo")
	public String findTrainingAndAuditInfo(@ModelAttribute("result") @Valid TrainingClassValidCommond commond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		String classId = commond.getClassId();
		if (PropertyUtil.objectNotEmpty(classId)) {
			TrainingClassValidCommond co = this.getService().find(classId);
			BeanUtils.copyProperties(co, commond);
			// 补全班级信息
			commond = trainingClassService.swapClassInfo(commond);
			// 获取班级审核信息
			ClassAuditInfoQueryCommond qCommond = new ClassAuditInfoQueryCommond();
			qCommond.setSearchClassId(classId);
			List<ClassAuditInfoValidCommond> list = (List<ClassAuditInfoValidCommond>) classAuditInfoService.findAllList(qCommond);
			// 从session中取出用户信息和用户Id
			com.eorchis.module.user.domain.User user = (com.eorchis.module.user.domain.User) request.getSession().getAttribute(SessionConstant.USER_INFO);
			commond.setAuditUserName(user.getUserName());
			commond.setAuditUserId(user.getUserId());
			if (list != null && list.size() > 0) {
				ClassAuditInfoValidCommond comm = list.get(0);
				ClassAuditInfo info = (ClassAuditInfo) comm.toEntity();
				commond.setAuditReason(info.getAuditReason());
			}
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("培训班ID为空");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}
		return "";
	}

	/**
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @date 2014-2-13
	 */
	public XMLGregorianCalendar convertToXMLGregorianCalendar(Date date) {

		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(date);
		XMLGregorianCalendar gc = null;
		try {
			gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
		} catch (Exception e) {

			e.printStackTrace();
		}
		return gc;
	}

	/**
	 * 单位报名班级列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author NiNgSS
	 * @createDate 2015-1-5
	 */
	@RequestMapping(value = "/findTrainingClassListByDept")
	public String findTrainingClassListByDept(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);
		if (attributeConverter != null) {
			parameterValueConvert(queryCommond, request, attributeConverter);
		}
		// 获得登陆者的管理范围
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(d) && PropertyUtil.objectNotEmpty(d.getDeptID())) {
			queryCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// queryCommond.setSearchTrainingApplyDeptId("8410");
			queryCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);// 活动班级
			queryCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);// 已发布班级
			// queryCommond.setAuditState(TrainingClass.IS_AUDIT_Y);//审核通过班级
			// 执行查询逻辑
			List<TrainingClassQueryBean> resultList = trainingClassService.findTrainingClassListByDept(queryCommond);
			onAfterFindList(resultList, queryCommond, request);
			// 存放结果
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		}
		return getModulePath() + "/list";
	}

	/**
	 * 单位报名班级列表
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author NiNgSS
	 * @createDate 2015-1-5
	 */
	@RequestMapping(value = "/findTrainingClassListByDeptFinish")
	public String findTrainingClassListByDeptFinish(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);
		if (attributeConverter != null) {
			parameterValueConvert(queryCommond, request, attributeConverter);
		}
		// 获得登陆者的管理范围
		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		if (PropertyUtil.objectNotEmpty(d) && PropertyUtil.objectNotEmpty(d.getDeptID())) {
			queryCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// queryCommond.setSearchTrainingApplyDeptId("8410");
			queryCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);// 活动班级
			queryCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);// 已发布班级
			// queryCommond.setAuditState(TrainingClass.IS_AUDIT_Y);//审核通过班级
			queryCommond.setSearchOpenState(TrainingClass.IS_ENDSTATE_Y);
			// 查询已发布的课程 by Max at 2015-04-03
			queryCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
			// 执行查询逻辑
			List<TrainingClassQueryBean> resultList = trainingClassService.findTrainingClassListByDeptFinish(queryCommond);
			onAfterFindList(resultList, queryCommond, request);
			// 存放结果
			queryCommond.setResultList(resultList);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("查询成功！");
		}
		return getModulePath() + "/list";
	}

	/**
	 * 查询用户可报名的班级列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月11日
	 */
	// @RequestMapping(value = "/findUserSignupClassList")
	// public String findUserSignupClassList(
	// @ModelAttribute("resultList") TrainingClassQueryCommond qCommond,
	// HttpServletRequest request, HttpServletResponse response,
	// @ModelAttribute("resultState") ResultState resultState) throws Exception
	// {
	//
	// User
	// user=(User)request.getSession().getAttribute(SessionConstant.USER_INFO);
	// qCommond.setSearchUserId(user.getUserId());
	// qCommond.setPage(2);
	// qCommond.setLimit(5);
	// //执行查询逻辑
	// List<TrainingClassQueryBean> resultList = trainingClassService
	// .findUserSignupClassList(qCommond);
	//
	// onAfterFindList(resultList, qCommond, request);
	// //存放结果
	// qCommond.setResultList(resultList);
	// resultState.setState(ResultState.RESULT_STATE_SUCCESS);
	// return getModulePath() + "/list";
	// }

	/**
	 * 查询中组部班级列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author ShenPS
	 * @date 2015年1月11日
	 */
	@RequestMapping(value = "/findClassListForZZB")
	public String findClassListForZZB(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		// 查询已上报的数据
		// if(qCommond.getSearchReportState()!=null){
		// qCommond.setSearchReportState(qCommond.getSearchReportState());
		// }else{
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		// }
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassList(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 查询中组部班级列表
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author GaoGQ
	 * @date 2015年3月26日
	 */
	@RequestMapping(value = "/findClassListForZZBFinish")
	public String findClassListForZZBFinish(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		// 查询已上报的数据
		// if(qCommond.getSearchReportState()!=null){
		// qCommond.setSearchReportState(qCommond.getSearchReportState());
		// }else{
		qCommond.setSearchReportState(TrainingClass.IS_REPORT_Y);
		// }
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// 设置结班状态
		qCommond.setSearchOpenState(TrainingClass.IS_ENDSTATE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassListFinish(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 导出选中的班级信息
	 * 
	 * @param qCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2015-1-27
	 */
	@RequestMapping(value = "/exportTrainingClasses")
	public void exportTrainingClasses(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);// 默认失败
		// String[]
		// searchClassIds={"402880975210ba6d015210bb52560001","402887934ad7f521014b0b5665870111"};
		// qCommond.setSearchClassIds(searchClassIds);
		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassIds())) {
			String ids = qCommond.getSearchClassIds()[0].toString();
			String[] classids = ids.split(",");
			qCommond.setSearchClassIds(classids);
			List<Sheet> sheetList = new ArrayList<Sheet>();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			for (String classId : qCommond.getSearchClassIds()) {
				// 根据班级id查询班级信息
				TrainingClassValidCommond co = this.getService().find(classId);
				// 补全班级信息
				// co=trainingClassService.swapClassInfo(co);
				// 将班级信息赋值到ExportClassBean
				List<ExportClassBean> exportClassBean = new ArrayList<ExportClassBean>();
				ExportClassBean eub = new ExportClassBean();
				eub.setClassNum(co.getClassNum());
				eub.setClassName(co.getClassName());
				eub.setSponsorName(co.getSponsorName());
				// eub.setMinistrieName(co.getMinistrieName());
				if (PropertyUtil.objectNotEmpty(co.getBeginDate())) {
					eub.setBeginDate(sdf.format(co.getBeginDate()));
				}
				if (PropertyUtil.objectNotEmpty(co.getEndDate())) {
					eub.setEndDate(sdf.format(co.getEndDate()));
				}
				String names = "";
				Iterator ite = co.getTrainingClass().getScopeDepartment().iterator();
				while (ite.hasNext()) {
					ClassScopeDepartment c = (ClassScopeDepartment) ite.next();
					names += c.getDept().getDeptName() + ",";
				}
				eub.setScopeDepartmentName(names.length() == 0 ? "" : names.substring(0, names.length() - 1));
				eub.setTrainingHour(co.getTrainingHour());
				eub.setClassDescription(co.getTrainingAddress());// 调训对象
				eub.setJointMinistrieName(co.getJointMinistrieName());// 合办部委
				exportClassBean.add(eub);
				// 根据班级id查询课程集合
				ClassCourseQueryCommond queryCommond = new ClassCourseQueryCommond();
				queryCommond.setSearchClassId(classId);
				List<ClassCourseQueryBean> resultList = classCourseService.findClassCourseAllList(queryCommond);
				// 将课程集合resultList赋值到exportClassCourseBean
				List<ExportClassCourseBean> exportClassCourseBean = new ArrayList<ExportClassCourseBean>();
				ExportClassCourseBean exportBean = null;
				for (ClassCourseQueryBean queryBean : resultList) {
					exportBean = new ExportClassCourseBean();
					exportBean.setCourseNum(queryBean.getCourseNum());
					exportBean.setCourseName(queryBean.getCourseName());
					exportBean.setSpeakDateStr(queryBean.getSpeakDate());
					exportBean.setSpeakTime(queryBean.getSpeakTimeStr());
					exportBean.setSpeakway(queryBean.getSpeakwayStr());
					exportBean.setSpeaker(queryBean.getSpeaker());
					exportBean.setSpeakDuty(queryBean.getSpeakDuty());
					exportBean.setSpeakdept(queryBean.getSpeakdept());
					exportClassCourseBean.add(exportBean);
				}
				// 存放结果
				TrainingClassAndCourseExport export = new TrainingClassAndCourseExport();
				export.setExportClassBean(exportClassBean);
				export.setExportClassCourseBean(exportClassCourseBean);
				TrainingClassSheet classSheet = new TrainingClassSheet();
				classSheet.setExportObject(export);
				classSheet.setExprotFormatName("trainingClassAndCourseExport");
				classSheet.setSheetName(co.getClassName());
				sheetList.add(classSheet);
			}
			Sheet[] sheetArray = new Sheet[sheetList.size()];// 导出Excel的Sheet集合
			for (int i = 0; i < sheetList.size(); i++) {
				sheetArray[i] = sheetList.get(i);
			}
			ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
			String title = "班级信息";
			response.setContentType("application/msexcel;charset=ISO8859-1");
			response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
			OutputStream out = response.getOutputStream();
			excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			resultState.setMessage("导出成功！");
		} else {
			resultState.setMessage("没有选中任何要导出的班级，请选择！");
		}
	}

	/**
	 * 查询培训班列表(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YangJC
	 * @createDate 2016-01-06
	 */
	@RequestMapping(value = "/queryTrainingClassList")
	public String queryTrainingClassList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}

		com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
		// qCommond.setSearchTrainingApplyDeptId("7449");
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// qCommond.setSearchAuditState(TrainingClass.IS_AUDIT_Y);
		qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		qCommond.setNotClassUserAuditState(1);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.queryTrainingClassList(qCommond);

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}

	/**
	 * 导出班级信息列表(委托部委办班)
	 * 
	 * @param commond
	 * @param bindingResult
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2016-1-6
	 */
	@RequestMapping(value = "/exportTrainingClassLists")
	public void exportTrainingClassLists(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		Role currentrole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		// 当前登录人部门ID
		qCommond.setSearchSponsorId(currentScope.getDeptID());

		// 当前登陆人角色 XXX 针对其他管理员只查询承办培训班,开放建班后可以去掉
		qCommond.setSearchRoleCode(currentrole.getCode());

		// 传递当前管理范围单位ID
		qCommond.setDeptId(currentScope.getDeptID());
		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		}
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findThematicClassList(qCommond);
		onAfterFindList(resultList, qCommond, request);
		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		for (TrainingClassQueryBean qcub : resultList) {
			ExportClassBean eub = new ExportClassBean();
			eub.setClassNum(qcub.getClassNum());// 班级编号
			eub.setClassName(qcub.getClassName());// 班级名称
			// eub.setMinistrieName(qcub.getMinistrieName());// 承办部委
			eub.setSponsorName(qcub.getSponsorName());// 主办单位
			// if (qcub.getClassUserNum() == -1) {
			// eub.setClassUserNum("不限");
			// } else {
			// eub.setClassUserNum(qcub.getClassUserNum().toString());// 计划调训人数
			// }
			eub.setTrainingHour(qcub.getTrainingHour());// 学制（天）
			eub.setBeginDate(qcub.getBeginDate());// 开班时间
			eub.setEndDate(qcub.getEndDate());// 结班时间
			eub.setEnterBeginTime(qcub.getEnterBeginTime());// 报名开始时间
			eub.setEnterEndTime(qcub.getEnterEndTime());// 报名结束时间
			eub.setClassDescription(qcub.getClassDescription());// 调训对象
			eub.setJointMinistrieName(qcub.getJointMinistrieName());// 调训对象
			// eub.setClassLevel(qcub.getClassLevel());
			classList.add(eub);
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("classListExportConfig");
		classSheet.setSheetName("班级信息列表");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "班级信息列表";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 培训班调训完成率(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YangJC
	 * @createDate 2016-01-08
	 */
	@RequestMapping(value = "/trainingClassStatistics")
	public String trainingClassStatistics(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();
		if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {// 部委管理员
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			qCommond.setSearchMinistrieID(d.getDeptID());
			// qCommond.setSearchMinistrieID("7498");
		} else if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {// 单位管理员
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			qCommond.setIsAsignCount(1);
			qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// qCommond.setSearchTrainingApplyDeptId("7449");
		}
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// qCommond.setSearchAuditState(TrainingClass.IS_AUDIT_Y);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = new ArrayList<TrainingClassQueryBean>();
		if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {
			resultList = trainingClassService.queryTrainingClassList(qCommond);
		} else {
			resultList = trainingClassService.findThematicClassList(qCommond);
		}
		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return "";
	}

	/**
	 * 导出培训班调训完成率(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YangJC
	 * @createDate 2016-01-08
	 */
	@RequestMapping(value = "/execlTrainingClassStatistics")
	public String execlTrainingClassStatistics(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}

		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();
		if (RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)) {// 部委管理员
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			qCommond.setSearchMinistrieID(d.getDeptID());
			// qCommond.setSearchMinistrieID("7498");
		} else if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {// 单位管理员
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			qCommond.setIsAsignCount(1);
			qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// qCommond.setSearchTrainingApplyDeptId("7449");
		}
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		// qCommond.setSearchAuditState(TrainingClass.IS_AUDIT_Y);
		qCommond.setLimit(-1);
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = new ArrayList<TrainingClassQueryBean>();
		if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {
			resultList = trainingClassService.queryTrainingClassList(qCommond);
		} else {
			resultList = trainingClassService.findThematicClassList(qCommond);
		}
		// 导出excel
		TrainingClassStatisticsExport export = new TrainingClassStatisticsExport();
		export.setExportTrainingClassBean(resultList);
		TrainingClassSheet trainingClassExport = new TrainingClassSheet();
		trainingClassExport.setExportObject(export);
		trainingClassExport.setExprotFormatName("exportTrainingClassStatistics");
		trainingClassExport.setSheetName("培训班调训完成率");
		Sheet[] sheetArray = new Sheet[] { trainingClassExport };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "培训班调训完成率";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return "";
	}

	/**
	 * 选取部委分类树(委托部委办班在线报名系统)
	 * 
	 * @param commond
	 * @return
	 * @throws Exception
	 * @author NingSS
	 * @createDate 2016-1-8
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/findBWDepartmentTree")
	public @ResponseBody List<JsonTreeBean> findBWDepartmentTree(DepartmentTreeCommond commond, HttpServletRequest request) throws Exception {
		List<JsonTreeBean> result = new ArrayList<JsonTreeBean>();
		Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
//		com.eorchis.module.security.cas.domain.Department  = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		commond.setProjectId(d.getDeptID());
		if (!PropertyUtil.objectNotEmpty(commond.getNode())) {
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			condition.setSearchTreeType(request.getParameter("searchTreeType"));
			condition.setSearchRoleCode(currentRole.getCode());
			JsonTreeBean rootBean = new JsonTreeBean();
			if (commond.getNode().equals(DeptConstants.DEPT_ROOT_ID) || currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_ONE_ADMIN)) {
				commond.setNode(DeptConstants.DEPT_ROOT_ID);
				BeanUtils.copyProperties(commond, condition);
				condition.setFindLeapNode(true);
				List<JsonTreeBean> list = departmentTreeService.doProcess(condition);
				rootBean.setText("北京市");
				rootBean.setLeaf(false);
				// rootBean.setChecked(false);
				rootBean.setId(DeptConstants.DEPT_ROOT_ID);
				rootBean.setChildren(list);
				rootBean.setState("close");
				rootBean.setExpandable(true);
				result.add(rootBean);
			} else {
				commond.setNode(d.getDeptID());
				BeanUtils.copyProperties(commond, condition);
				condition.setFindLeapNode(true);
				if (RoleConstants.ROLE_CODE_TWO_ADMIN.equals(currentRole.getRoleCode())) {
					List<Object[]> list = (List<Object[]>) trainingClassService.findAdminLevel(condition);
					condition.setNode(list.get(0)[0].toString());
					commond.setNode(condition.getNode());
					rootBean.setText(list.get(0)[2].toString());
				}
				List<JsonTreeBean> list = departmentTreeService.doProcess(condition);
				if (!PropertyUtil.objectNotEmpty(rootBean.getText())) {
					rootBean.setText(d.getDeptName());
				}
				rootBean.setLeaf(false);
				// rootBean.setChecked(false);
				rootBean.setId(commond.getNode());
				rootBean.setChildren(list);
				rootBean.setState("close");
				rootBean.setExpandable(true);
				result.add(rootBean);
			}
		} else {
			DepartmentTreeCondition condition = new DepartmentTreeCondition();
			condition.setSearchTreeType(request.getParameter("searchTreeType"));
			condition.setSearchRoleCode(currentRole.getCode());
			condition.setSearchFrameType(request.getParameter("searchFrameType"));
			BeanUtils.copyProperties(commond, condition);
			condition.setFindLeapNode(true);
			// 一级管理员建班查询承办单位时传递
			if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_ONE_ADMIN))
				condition.setSearchType(DeptConstants.DEPT_LEVEL_CODE_LV1);
			if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_TWO_ADMIN)) {
				List<Object[]> list = (List<Object[]>) trainingClassService.findAdminLevel(condition);
				condition.setSearchTreepath(list.get(0)[1].toString());
			}
			result = departmentTreeService.doProcess(condition);
		}
		return result;
	}

	/**
	 * 培训班名额统计(查看报名状态页面)(委托部委办班在线报名系统)
	 * 
	 * @param queryCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author YangJC
	 * @createDate 2016-01-08
	 */
	@RequestMapping(value = "/trainingClassCount")
	public String trainingClassCount(@ModelAttribute("result") TrainingClassQueryBean validCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();
		if (RoleConstants.ROLE_CODE_DW_ADMIN.equals(roleCode)) {// 单位管理员
			TrainingClassQueryCommond qCommond = new TrainingClassQueryCommond();
			com.eorchis.module.security.cas.domain.Department d = (com.eorchis.module.security.cas.domain.Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
			qCommond.setSearchTrainingApplyDeptId(d.getDeptID());
			// qCommond.setSearchTrainingApplyDeptId("7449");
			qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
			qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
			// qCommond.setSearchAuditState(TrainingClass.IS_AUDIT_Y);
			qCommond.setSearchClassIds(new String[] { request.getParameter("searchClassId") });
			qCommond.setNotClassUserAuditState(1);
			// 执行查询逻辑
			List<TrainingClassQueryBean> resultList = trainingClassService.queryTrainingClassList(qCommond);
			// 存放结果
			if (PropertyUtil.objectNotEmpty(resultList) && resultList.size() > 0) {
				BeanUtils.copyProperties(resultList.get(0), validCommond);
			}
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {// 中组部管理员和部委管理员 add by NingSS at 2016-1-18
			TrainingClassQueryCommond queryCommond = new TrainingClassQueryCommond();
			queryCommond.setSearchClassId(request.getParameter("searchClassId"));
			if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassId())) {
				queryCommond.setTreePath(DeptConstants.SIGN_DEPT_TREEPATH);
				List<TrainingClassQueryBean> resultList = trainingClassService.findClassUserAsignCount(queryCommond);
				if (PropertyUtil.objectNotEmpty(resultList) && resultList.size() > 0) {
					BeanUtils.copyProperties(resultList.get(0), validCommond);
				}
				resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			} else {
				resultState.setMessage("未选中任何班");
			}
		}
		return "";
	}

	/**
	 * 上传班级选调函
	 * 
	 * @param commond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2016-1-15
	 */
	@RequestMapping(value = "/uploadSelectedLetters")
	public String uploadSelectedLetters(Model modle, @ModelAttribute("result") @Valid TrainingClassValidCommond commond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if (token.isTokenValid(request, true)) {//判断token
		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		for (MultipartFile multipartFile : fileMap.values()) {
			CommonsMultipartFile commonsMultipartFile = (CommonsMultipartFile) multipartFile;
			FileItem item = commonsMultipartFile.getFileItem();
			// File item = new File("D:\\导入1.xls");
			// FileInputStream fis = new FileInputStream(item);
			if (!item.isFormField()) {
				if (item.getSize() == 0) {// 附件为空
					resultState.setMessage("您上传的附件内容为空！");
					resultState.setState(ResultState.RESULT_STATE_FAIL);
					return "";
				}
				if (item.getSize() > getUploadConfig(request).getSizeMax()) {// 附件大小超出限制
					resultState.setMessage("您上传的附件太大！");
					resultState.setState(ResultState.RESULT_STATE_FAIL);
					return "";
				}
				if (!StringUtils.isContain(FilenameUtils.getExtension(item.getName()), getUploadConfig(request).getFileExtension(), true) && !StringUtils.isContain("*", getUploadConfig(request).getFileExtension())) {// 配置中不包含的附件扩展名
					resultState.setMessage("不支持您上传的附件类型！");
					resultState.setState(ResultState.RESULT_STATE_FAIL);
					return "";
				}
				AttachmentCommond attachmentCommond = makeCommond(null, item);
				try {
					// attachmentService.save(attachmentCommond);//添加附件记录
					// attachmentService.getStorage().setAttachmentContent(attachmentCommond,item.getInputStream());//保存附件

					// RongSL 解决非flash模式下的上传文件问题
					BaseAttachment ba = new BaseAttachment();
					byte bytes[] = multipartFile.getBytes();
					String name = item.getName();
					String attName = name.substring(0, name.lastIndexOf("."));
					ba.setFileName(attName);
					String fileType = name.substring(name.lastIndexOf(".") + 1);
					ba.setFileType(fileType);
					ba.setContent(Hibernate.createBlob(bytes));
					ba.setFileSize(Integer.valueOf(item.getSize() + ""));
					ba.setPrimevalFileName(name);
					ba.setMimeType(item.getContentType());
					ba.setUploadDate(new Date());
					ba = trainingClassService.saveBaseAttachment(ba);

					TrainingClassValidCommond trainingClass = new TrainingClassValidCommond();
					trainingClass = trainingClassService.find(commond.getClassId());
					if (PropertyUtil.objectNotEmpty(trainingClass.getSelectedLetters()))
						attachmentService.delete(new String[] { trainingClass.getSelectedLetters() });// 如果存在则删除附件记录
					// 附件添加成功后和班级进行关联
					String attId = ba.getAttachmentId();
					trainingClass.setSelectedLetters(attId);
					trainingClassService.update(trainingClass);
					resultState.setState(ResultState.RESULT_STATE_SUCCESS);
					resultState.setMessage("上传成功！");
				} catch (Exception e) {
					if (attachmentCommond.getAttachmentID() != null) {
						attachmentService.delete(new String[] { attachmentCommond.getAttachmentID() });// 异常状态删除附件记录
					}
					throw new RuntimeException("get file stream exception.file name:" + FilenameUtils.getName(item.getName()), e);
				} finally {
					// item.delete();
				}
			}
		}
		/*
		 * } else {
		 * resultState.setState(ResultState.RESULT_STATE_REPEAT_SUBMIT);//重复提交
		 * resultState.setMessage("重复提交"); }
		 */
		return "";
	}

	/**
	 * 上传学员心得
	 * 
	 * @param commond
	 * @param request
	 * @param response
	 * @param resultState
	 * @return
	 * @throws Exception
	 * @author RongSL
	 * @createDate 2016-1-15
	 */
	@RequestMapping(value = "/uploadExperience")
	public String uploadExperience(Model modle, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		// if (token.isTokenValid(request, true)) {//判断token
		String classUserId = request.getParameter("classUserId");
		if (!PropertyUtil.objectNotEmpty(classUserId)) {
			resultState.setMessage("缺少参数，请重新上传！");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
			return "";
		}
		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		for (MultipartFile multipartFile : fileMap.values()) {
			CommonsMultipartFile commonsMultipartFile = (CommonsMultipartFile) multipartFile;
			FileItem item = commonsMultipartFile.getFileItem();
			// File item = new File("D:\\导入1.xls");
			// FileInputStream fis = new FileInputStream(item);
			if (!item.isFormField()) {
				if (item.getSize() == 0) {// 附件为空
					resultState.setMessage("您上传的附件内容为空！");
					resultState.setState(ResultState.RESULT_STATE_FAIL);
					return "";
				}
				// if (item.getSize() > getUploadConfig(request).getSizeMax())
				// {// 附件大小超出限制
				// resultState.setMessage("您上传的附件太大！");
				// resultState.setState(ResultState.RESULT_STATE_FAIL);
				// return "";
				// }
				if (!StringUtils.isContain(FilenameUtils.getExtension(item.getName()), new String[] { "doc", "docx", "xls", "xlsx", "pdf", "rar", "zip" }, true)) {// 配置中不包含的附件扩展名
					resultState.setMessage("不支持您上传的附件类型！");
					resultState.setState(ResultState.RESULT_STATE_FAIL);
					return "";
				}
				AttachmentCommond attachmentCommond = makeCommond(null, item);
				try {
					// attachmentService.save(attachmentCommond);//添加附件记录
					// attachmentService.getStorage().setAttachmentContent(attachmentCommond,item.getInputStream());//保存附件

					// RongSL 解决非flash模式下的上传文件问题
					BaseAttachment ba = new BaseAttachment();
					byte bytes[] = multipartFile.getBytes();
					String name = item.getName();
					String attName = name.substring(0, name.lastIndexOf("."));
					ba.setFileName(attName);
					String fileType = name.substring(name.lastIndexOf(".") + 1);
					ba.setFileType(fileType);
					ba.setContent(Hibernate.createBlob(bytes));
					ba.setFileSize(Integer.valueOf(item.getSize() + ""));
					ba.setPrimevalFileName(name);
					ba.setMimeType(item.getContentType());
					ba.setUploadDate(new Date());
					ba = trainingClassService.saveBaseAttachment(ba);

					// 更新学员附件
					try {
						classUserDao.updateUserAttachment(new String[] { ba.getAttachmentId(), classUserId });
					} catch (Exception e) {
						attachmentCommond.setAttachmentID(ba.getAttachmentId());
						attachmentService.delete(attachmentCommond);// 如果存在则删除附件记录
						e.printStackTrace();
					}
					resultState.setState(ResultState.RESULT_STATE_SUCCESS);
					resultState.setMessage("上传成功！");
				} catch (Exception e) {
					if (attachmentCommond.getAttachmentID() != null) {
						attachmentService.delete(new String[] { attachmentCommond.getAttachmentID() });// 异常状态删除附件记录
					}
					throw new RuntimeException("get file stream exception.file name:" + FilenameUtils.getName(item.getName()), e);
				} finally {
					// item.delete();
				}
			}
		}
		/*
		 * } else {
		 * resultState.setState(ResultState.RESULT_STATE_REPEAT_SUBMIT);//重复提交
		 * resultState.setMessage("重复提交"); }
		 */
		return "forward:/module/classuser/findLearningExperienceList.do";
	}

	@RequestMapping("/settingUserAttachments")
	public String settingUserAttachments(HttpServletRequest request, ClassUserQueryCommond queryCommond, @ModelAttribute("resultState") ResultState resultState, HttpServletResponse response) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);
		try {
			if (PropertyUtil.objectNotEmpty(queryCommond.getAttachmentIds())) {
				for (String s : queryCommond.getAttachmentIds()) {
					if (PropertyUtil.objectNotEmpty(s)) {
						AttachmentCommond attachmentCommond = new AttachmentCommond();
						attachmentCommond.setAttachmentID(s);
						attachmentService.delete(attachmentCommond);// 删除附件
					}
				}
				// 批量设置学员上传附件ID为空
				classUserDao.settingUserAttachments(queryCommond);
				resultState.setState(ResultState.RESULT_STATE_SUCCESS);
			} else {
				resultState.setMessage("缺少附件ID!");
			}
		} catch (Exception e) {
			e.printStackTrace();
			resultState.setMessage("删除失败，请联系管理员!");
		}
		return "";
	}

	/**
	 * 获取上传配置对象，首先根据requestURI寻找是否为其配置了独立的上传配置，有则返回，如果没有找到则检测是否配置了全局配置，有则返回，
	 * 如果没有则返回默认的上传配置，即：不限制文件类型，不统计下载数量，且单个文件上传大小限制为5MB
	 * 
	 * @return 上传配置对象
	 */
	protected UploadConfig getUploadConfig(HttpServletRequest request) {
		String requestURI = request.getRequestURI();
		UploadConfig uploadConfig = attachmentService.getUploadConfig(requestURI);
		if (uploadConfig == null) {
			uploadConfig = attachmentService.getUploadConfig();
			// 如果上传设置上传配置，则使用默认配置，即：接受所有文件类型，且上传限制为5MB
			if (uploadConfig == null) {
				uploadConfig = new UploadConfig();
				uploadConfig.setConfigCode("Default");
				uploadConfig.setFileExtension(new String[] { "pdf", "doc", "docx", "xls", "xlsx" });
				uploadConfig.setSizeMax(102500 * 1024 * 5L);
				uploadConfig.setNeedStatistics(false);
			}
		}
		return uploadConfig;
	}

	/**
	 * 根据文件对象封装附件Commond对象
	 * 
	 * @param groupCode
	 * @param item
	 * @return
	 */
	private AttachmentCommond makeCommond(String groupCode, FileItem item) {
		String fileName = FilenameUtils.getName(item.getName());
		AttachmentCommond attachmentCommond = new AttachmentCommond();
		attachmentCommond.setDownloadNumber(0);
		attachmentCommond.setFileName(UUID.randomUUID().toString());
		attachmentCommond.setFileSize(item.getSize());
		attachmentCommond.setPrimevalFileName(fileName);
		attachmentCommond.setFileType(FilenameUtils.getExtension(fileName));
		attachmentCommond.setMimeType(item.getContentType());
		attachmentCommond.setGroupCode(groupCode);
		attachmentCommond.setModifiabilityScope(Attachment.MODIFIABILITY_SCOPE_PUBLIC);
		attachmentCommond.setUploadDate(new Date());
		return attachmentCommond;
	}

	/**
	 * @category 查询班级的报名情况(中组部管理员和部委管理员报名审核页面)(委托部委办班在线报名系统)
	 * @param validCommond
	 * @throws Exception
	 * @author NingSS
	 * @return
	 */
	@RequestMapping(value = "/findClassUserAsignCount")
	public String findClassUserAsignCount(@ModelAttribute("result") TrainingClassQueryBean validCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		resultState.setState(ResultState.RESULT_STATE_FAIL);
		TrainingClassQueryCommond queryCommond = new TrainingClassQueryCommond();
		queryCommond.setSearchClassId(request.getParameter("searchClassId"));
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchClassId())) {
			queryCommond.setTreePath(DeptConstants.SIGN_DEPT_TREEPATH);
			List<TrainingClassQueryBean> resultList = trainingClassService.findClassUserAsignCount(queryCommond);
			if (PropertyUtil.objectNotEmpty(resultList) && resultList.size() > 0) {
				BeanUtils.copyProperties(resultList.get(0), validCommond);
			}
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} else {
			resultState.setMessage("未选中任何班");
		}
		return "";
	}

	/**
	 * @category 查看二维码
	 * @param vCommond
	 * @throws Exception
	 * @author NingSS
	 * @return
	 */
	@RequestMapping(value = "/findErweima")
	public String findErweima(@ModelAttribute("result") TrainingClassValidCommond vCommond, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		if (PropertyUtil.objectNotEmpty(vCommond.getClassId())) {
			TrainingClassValidCommond co = this.getService().find(vCommond.getClassId());
			if (PropertyUtil.objectNotEmpty(co)) {
				model.addAttribute("classId", vCommond.getClassId());
				model.addAttribute("className", co.getClassName());
				model.addAttribute("questionnaireUrl", co.getQuestionnaireUrl());
				return "forward:/portal/project/erweima/erweima.jsp";
			}
		}
		return "";
	}

	/**
	 * @评估查询
	 * @Name: findClassUserAsignCount
	 * @Description: @param validCommond
	 * @Description: @param request
	 * @Description: @param response
	 * @Description: @param resultState
	 * @Description: @return
	 * @Description: @throws Exception
	 * @Author: GUOLEI
	 * @Version: V1.00
	 * @Create Date: 2016-2-6下午12:19:12
	 * @Parameters: TrainingClassController
	 * @Return: String
	 */
	@RequestMapping(value = "/findClassAssessmentt")
	public String findClassAssessmentt(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// if (!RoleConstants.ROLE_CODE_GJC_ADMIN.equals(roleCode)) {// 部委管理员
		qCommond.setSearchSponsorId(currentScope.getDeptID());

		// XXX 一级不能建班时暂用
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();
		qCommond.setSearchRoleCode(roleCode);
		// // qCommond.setSearchMinistrieID("7498");
		// }
		List<TrainingClassQueryBean> resultList = trainingClassService.findClassAssessmentt(qCommond);
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return "";
	}

	/**
	 * @评估进度查询&评估结果查询
	 * @Name: findClassSchedule
	 * @Description: @param validCommond
	 * @Description: @param request
	 * @Description: @param response
	 * @Description: @param resultState
	 * @Description: @return
	 * @Description: @throws Exception
	 * @Author: RongSL
	 * @Version: V1.00
	 * @Create Date: 2017-2-23
	 * @Parameters: TrainingClassController
	 * @Return: String
	 */
	@RequestMapping(value = "/findClassSchedule")
	public String findClassSchedule(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// if (!RoleConstants.ROLE_CODE_GJC_ADMIN.equals(roleCode)) {// 部委管理员
		qCommond.setSearchSponsorId(currentScope.getDeptID());

		// XXX 一级不能建班时暂用
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();
		qCommond.setSearchRoleCode(roleCode);
		// // qCommond.setSearchMinistrieID("7498");
		// }
		// 只查询已开班
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);
		List<TrainingClassQueryBean> resultList = trainingClassService.findClassAssessmentt(qCommond);
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return "";
	}

	/**
	 * @评估人员
	 * @Name: findAnswerUser
	 * @Description: @param queryCommond
	 * @Description: @throws Exception
	 * @Author: RongSL
	 * @Version: V1.00
	 * @Create Date: 2016-2-16
	 * @Return: String
	 */
	@RequestMapping(value = "/findAnswerUser")
	public String findAnswerUser(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		List<BaseUserBean> resultList = trainingClassService.findAnswerUser(queryCommond);
		queryCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return "";
	}

	/**
	 * @导出评估
	 * @Name: findClassUserAsignCount
	 * @Description: @param validCommond
	 * @Description: @param request
	 * @Description: @param response
	 * @Description: @param resultState
	 * @Description: @return
	 * @Description: @throws Exception
	 * @Author: GUOLEI
	 * @Version: V1.00
	 * @Create Date: 2016-2-6下午12:19:12
	 * @Parameters: TrainingClassController
	 * @Return: String
	 */
	@RequestMapping(value = "/exportClassAssessmentt")
	public void exportClassAssessmentt(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		qCommond.setPageo(-1);
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		qCommond.setSearchSponsorId(currentScope.getDeptID());
		// 只查询已开班
		qCommond.setSearchPublishState(TrainingClass.IS_PUBLISH_Y);

		// XXX 一级不能建班时暂用
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		String roleCode = currentRole.getCode();
		qCommond.setSearchRoleCode(roleCode);

		List<TrainingClassQueryBean> resultList = trainingClassService.findClassAssessmentt(qCommond);
		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		if (PropertyUtil.objectNotEmpty(resultList)) {
			for (TrainingClassQueryBean qcub : resultList) {
				ExportClassBean eub = new ExportClassBean();
				eub.setClassNum(qcub.getClassNum());// 班级编号
				eub.setClassName(qcub.getClassName());// 班级名称
				eub.setSponsorName(qcub.getSponsorName());// 主办单位
				eub.setBeginDate(qcub.getBeginDate());// 开班时间
				eub.setEndDate(qcub.getEndDate());// 结班时间
				// eub.setPlanCount(qcub.getPlanCount());// 已报人数
				// eub.setReportedNum(qcub.getReportedNum());// 计划人数
				eub.setAnswerUser(qcub.getAnswerUser());// 以评估人数
				eub.setNoAnswerUser(qcub.getNoAnswerUser());// 未评估人数
				eub.setNswerPerc(qcub.getNswerPerc());// 参评率
				eub.setAssessStartTime(qcub.getAssessStartTime());// 评估开始时间
				eub.setAssessEndTime(qcub.getAssessEndTime());// 评估结束时间
				classList.add(eub);
			}
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("classAssessmenttExportConfig");
		classSheet.setSheetName("评估进度列表");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "评估进度列表";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * @导出课程评估
	 * @Name: findClassUserAsignCount
	 * @Description: @param validCommond
	 * @Author: RongSL
	 * @Version: V1.00
	 * @CreateDate: 2016-5-20
	 * @Parameters: TrainingClassController
	 * @Return: String
	 */
	@RequestMapping(value = "/exportClassAssessment")
	public void exportCourseAssessment(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		qCommond.setPageo(-1);
		// Role currentRole =
		// (Role)request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		// Department currentScope = (Department)
		// request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// String roleCode = currentRole.getCode();
		// if(RoleConstants.ROLE_CODE_BW_ADMIN.equals(roleCode)){//部委管理员
		// qCommond.setSearchMinistrieID(currentScope.getDeptID());
		// //qCommond.setSearchMinistrieID("7498");
		// }
		List<TrainingClassQueryBean> resultList = trainingClassService.findCourseAssessment(qCommond);
		List<ExportClassBean> classList = new ArrayList<ExportClassBean>();
		if (PropertyUtil.objectNotEmpty(resultList)) {
			for (TrainingClassQueryBean qcub : resultList) {
				ExportClassBean eub = new ExportClassBean();
				eub.setCourseName(qcub.getCourseName());// 课程名称
				eub.setCourseNum(qcub.getCourseNum());// 课程编号
				eub.setAnswerUser(qcub.getAnswerUser());// 以评估人数
				eub.setNoAnswerUser(qcub.getNoAnswerUser());// 未评估人数
				eub.setNswerPerc(qcub.getNswerPerc());// 参评率
				classList.add(eub);
			}
		}
		TrainingClassExport classExport = new TrainingClassExport();
		classExport.setExportClassBean(classList);
		TrainingClassSheet classSheet = new TrainingClassSheet();
		classSheet.setExportObject(classExport);
		classSheet.setExprotFormatName("courseAssessmenttExportConfig");
		classSheet.setSheetName("课程评估进度列表");

		Sheet[] sheetArray = new Sheet[] { classSheet };// 导出Excel的Sheet集合
		ExcelIO excelio = ExcelIOFactory.getExcelIO();// Excel导出工具
		String title = "课程评估进度列表";
		response.setContentType("application/msexcel;charset=ISO8859-1");
		response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(title, "UTF-8") + ".xls");
		OutputStream out = response.getOutputStream();
		excelio.exportExcel(out, "resumeExportStyle", sheetArray, false);
	}

	/**
	 * 修改培训班信息
	 * 
	 * @param vCommond
	 * @param request
	 * @param response
	 * @param resultState
	 * @throws Exception
	 * @author LongJZ
	 * @createDate 2016-4-18
	 */
	@RequestMapping(value = "/updateAssessTime")
	public String updateAssessTime(@ModelAttribute("result") TrainingClassValidCommond vCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (PropertyUtil.objectNotEmpty(vCommond.getClassId()) && PropertyUtil.objectNotEmpty(vCommond.getAssessStartTimeStr()) && PropertyUtil.objectNotEmpty(vCommond.getAssessEndTimeStr())) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			vCommond.setAssessStartTime(sdf.parse(vCommond.getAssessStartTimeStr()));
			vCommond.setAssessEndTime(sdf.parse(vCommond.getAssessEndTimeStr()));
			trainingClassService.updateAssessTime(vCommond);
			resultState.setMessage("保存成功");
		} else {
			resultState.setMessage("缺少参数");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		}
		return "";
	}

	/**
	 * @课程评估人员
	 * @Name: findAnswerUser
	 * @Description: @param queryCommond
	 * @Description: @throws Exception
	 * @Author: RongSL
	 * @Version: V1.00
	 * @Create Date: 2016-5-30
	 * @Return: String
	 */
	@RequestMapping(value = "/findCourseAnswerUser")
	public String findCourseAnswerUser(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		List<BaseUserBean> resultList = trainingClassService.findCourseAnswerUser(queryCommond);
		queryCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return "";
	}

	/**
	 * 查询子部门
	 * 
	 * @Date 2016-12-27
	 * @author RongSL
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/findDepartmentList")
	public String findDepartmentList(HttpServletRequest request, TrainingClassQueryCommond queryCommond) throws Exception {
		DepartmentValidCommond commond = new DepartmentValidCommond();
		commond.setDeptIds(queryCommond.getDeptIds());
		commond.setParentID(queryCommond.getParentId());
		Department casDept = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		Role currentRole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		DepartmentTreeCondition condition = new DepartmentTreeCondition();
		condition.setFindLeapNode(true);
		condition.setProjectId(casDept.getDeptID());
		if (PropertyUtil.objectNotEmpty(queryCommond.getNoDeptID()) && PropertyUtil.objectNotEmpty(queryCommond.getNoDeptID()[0])) {
			condition.setNoDeptID(queryCommond.getNoDeptID()[0].split(","));
		}
		if (PropertyUtil.objectNotEmpty(queryCommond.getSearchDepName())) {
			condition.setSearchDepName(queryCommond.getSearchDepName());
		}
		// if(!PropertyUtil.objectNotEmpty(queryCommond.getDeptId())){
		// queryCommond.setDeptId(casDept.getDeptID());
		// if (queryCommond.getDeptId().equals(DeptConstants.DEPT_ROOT_ID) ||
		// currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_ONE_ADMIN))
		// condition.setNode(DeptConstants.DEPT_ROOT_ID);
		// else
		// condition.setNode(queryCommond.getDeptId());
		// }else{
		// // 一级管理员建班查询承办单位时传递
		// if
		// (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_ONE_ADMIN))
		// condition.setSearchType(DeptConstants.DEPT_LEVEL_CODE_LV1);
		// condition.setNode(queryCommond.getDeptId());
		// }
		// condition.setSearchTreeType(request.getParameter("searchFrameType"));
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_TWO_ADMIN) && !PropertyUtil.objectNotEmpty(queryCommond.getDeptId())) {
			// condition.setSearchDepID(casDept.getDeptID());
			condition.setNode(casDept.getDeptID());
			List<Object[]> list = (List<Object[]>) trainingClassService.findAdminLevel(condition);
			if (PropertyUtil.objectNotEmpty(list) && PropertyUtil.objectNotEmpty(list.get(0))) {
				condition.setSearchTreepath(list.get(0)[1].toString());
			}
		} else if (!PropertyUtil.objectNotEmpty(queryCommond.getDeptId())) {
			queryCommond.setDeptId(DeptConstants.DEPT_ROOT_ID);
		} else {
			condition.setNode(queryCommond.getDeptId());
		}
		if (currentRole.getRoleCode().equals(RoleConstants.ROLE_CODE_ONE_ADMIN))
			condition.setSearchType(DeptConstants.DEPT_LEVEL_CODE_LV1);
		if (PropertyUtil.objectNotEmpty(queryCommond.getDeptId())) {
			Department dep = classUserDao.find(Department.class, queryCommond.getDeptId());
			condition.setSearchTreepath(dep.getTreepath());
			// condition.setSearchTreeType(queryCommond.getSearchTreeType());
			condition.setSearchFrameType(queryCommond.getSearchFrameType());
		}
		queryCommond.getPage();
		queryCommond.getLimit();
		if (queryCommond.getPage() == 1) {
			condition.setStartPage(queryCommond.getLimit());
			condition.setEndPage(0);
		} else {
			condition.setStartPage(queryCommond.getLimit() * queryCommond.getPage());
			condition.setEndPage(queryCommond.getLimit() * (queryCommond.getPage() - 1));
		}
		condition.setSearchRoleCode(currentRole.getRoleCode());

		List<Department> resultList = departmentTreeSyncManager.listUnSeclectDepartmentTree(condition);
		queryCommond.setCount(condition.getCountPage());
		queryCommond.setResultList(resultList);
		return "";
	}

	public XMLGregorianCalendar dateToXMLGregorianCalendar(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		DatatypeFactory dtf = null;
		try {
			dtf = DatatypeFactory.newInstance();
		} catch (DatatypeConfigurationException e) {
		}
		XMLGregorianCalendar dateType = dtf.newXMLGregorianCalendar();
		dateType.setYear(cal.get(Calendar.YEAR));
		// 由于Calendar.MONTH取值范围为0~11,需要加1
		dateType.setMonth(cal.get(Calendar.MONTH) + 1);
		dateType.setDay(cal.get(Calendar.DAY_OF_MONTH));
		dateType.setHour(cal.get(Calendar.HOUR_OF_DAY));
		dateType.setMinute(cal.get(Calendar.MINUTE));
		dateType.setSecond(cal.get(Calendar.SECOND));
		return dateType;
	}

	@RequestMapping("/preAddTraining2")
	public void preAddTraining2(@ModelAttribute("result") TrainingClassValidCommond validCommond, HttpServletRequest request, HttpServletResponse response) {
		// String classNum=trainingClassService.getTrainingClassNum();
		// classNum=(Integer.valueOf(classNum)+1)+"";
		Department currentDepartment = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		Writer w = null;
		// validCommond.setClassNum(classNum);
		validCommond.setSponsorID(currentDepartment.getDeptID());
		validCommond.setSponsorName(currentDepartment.getDeptName());

		// 当前管理范围
		Role currentrole = (Role) request.getSession().getAttribute(SessionConstant.CURRENT_ROLE);
		// 当前管理部门
		Department d = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// 当时超级管理员的时候替换名字
		if (PropertyUtil.objectNotEmpty(currentrole) && currentrole.getRoleCode().equals(RoleConstants.ROLE_CODE_GJC_ADMIN)) {
			if (DeptConstants.DEPT_NAME_CONVERT.containsKey(d.getDeptName())) {
				validCommond.setSponsorName(DeptConstants.DEPT_NAME_CONVERT.get(d.getDeptName()));
			}
		}

		try {
			w = response.getWriter();
			Object o = JSONObject.toJSON(validCommond);
			w.write(o.toString());
			w.flush();
			w.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 批量更新问卷评估方式
	 * 
	 * @author RongSl
	 * @Date 2017-02-13
	 */
	@RequestMapping("/updateQuestionnaireMethod")
	public void updateQuestionnaireMethod(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) {
		PrintWriter pw = null;
		try {
			pw = response.getWriter();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		try {
			trainingClassService.updateQuestionnaireMethod(queryCommond);
			resultState.setMessage("设置成功!");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} catch (Exception e) {
			e.printStackTrace();
			resultState.setMessage("设置失败，请联系管理员!");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		} finally {
			pw.append(JSON.toJSONString(resultState));
			pw.flush();
			pw.close();
		}
	}

	/**
	 * 考核详情
	 * 
	 * @author RongSl
	 * @Date 2017-05-15
	 */
	@RequestMapping("/assessdetails")
	public void assessdetails(@ModelAttribute("resultList") TrainingClassQueryCommond queryCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) {
		PrintWriter pw = null;
		try {
			pw = response.getWriter();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		try {
			trainingClassService.updateQuestionnaireMethod(queryCommond);
			resultState.setMessage("设置成功!");
			resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		} catch (Exception e) {
			e.printStackTrace();
			resultState.setMessage("设置失败，请联系管理员!");
			resultState.setState(ResultState.RESULT_STATE_FAIL);
		} finally {
			pw.append(JSON.toJSONString(resultState));
			pw.flush();
			pw.close();
		}
	}

	
	
	@RequestMapping(value = "/findUserTrainingClassList")
	public String findUserTrainingClassList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// 当前登录人
		qCommond.setSearchSponsorId(currentScope.getDeptID());
		// 传递当前管理范围单位ID
		qCommond.setDeptId(currentScope.getDeptID());
		//获取用户信息
		User user=(User) request.getSession().getAttribute(SessionConstant.USER_INFO);
		if (!PropertyUtil.objectNotEmpty(qCommond.getSearchUserId())) {
			qCommond.setSearchUserId(user.getUserId());
		}
		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		}
		qCommond.setTreePath(currentScope.getTreepath());
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		if(PropertyUtil.objectNotEmpty(qCommond.getSearchYear())){
			if(qCommond.getSearchYear().equals("合计")){
				qCommond.setSearchYear(null);
			}
		}
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findAuditTrainingClassList(qCommond);

		// Department department = classUserDao.find(Department.class,
		// currentScope.getDeptID());
		// String levelCode=null;
		// int i=department.getTreepath().split("/").length;
		// if(PropertyUtil.objectNotEmpty(department.getAdminLevelCode())){
		// levelCode = department.getAdminLevelCode();
		// }else if(i==3){ //当管理范围为北京市下的无级别机构时默认为一级机构去处理
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_ONE);
		// }
		// qCommond.setSearchMinistrieID(currentScope.getDeptID());
		// 加入所属机构判断
		// qCommond.setTreePath(department.getTreepath());
		// if (TrainingClass.MECHANISM_TYPE_ONE.equals(levelCode)) {// 一级管理员
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_ONE);
		// } else if (TrainingClass.MECHANISM_TYPE_ONE.equals(levelCode)) {//
		// 二级管理员
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_TWO);
		// }

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}
	
	
	
	
	@RequestMapping(value = "/findAuditTrainingClassList")
	public String findAuditTrainingClassList(@ModelAttribute("resultList") TrainingClassQueryCommond qCommond, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("resultState") ResultState resultState) throws Exception {
		if (attributeConverter != null) {
			parameterValueConvert(qCommond, request, attributeConverter);
		}
		Department currentScope = (Department) request.getSession().getAttribute(SessionConstant.CURRENT_SCOPE);
		// 当前登录人
		qCommond.setSearchSponsorId(currentScope.getDeptID());
		// 传递当前管理范围单位ID
		qCommond.setDeptId(currentScope.getDeptID());
		
		if (PropertyUtil.objectNotEmpty(qCommond.getSearchClassNum())) {
			qCommond.setSearchTrainingNum(qCommond.getSearchClassNum());
		}
		qCommond.setTreePath(currentScope.getTreepath());
		qCommond.setSearchActiveState(TrainingClass.IS_ACTIVE_Y);
		if(PropertyUtil.objectNotEmpty(qCommond.getSearchYear())){
			if(qCommond.getSearchYear().equals("合计")){
				qCommond.setSearchYear(null);
			}
		}
		// 执行查询逻辑
		List<TrainingClassQueryBean> resultList = trainingClassService.findAuditTrainingClassList(qCommond);

		// Department department = classUserDao.find(Department.class,
		// currentScope.getDeptID());
		// String levelCode=null;
		// int i=department.getTreepath().split("/").length;
		// if(PropertyUtil.objectNotEmpty(department.getAdminLevelCode())){
		// levelCode = department.getAdminLevelCode();
		// }else if(i==3){ //当管理范围为北京市下的无级别机构时默认为一级机构去处理
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_ONE);
		// }
		// qCommond.setSearchMinistrieID(currentScope.getDeptID());
		// 加入所属机构判断
		// qCommond.setTreePath(department.getTreepath());
		// if (TrainingClass.MECHANISM_TYPE_ONE.equals(levelCode)) {// 一级管理员
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_ONE);
		// } else if (TrainingClass.MECHANISM_TYPE_ONE.equals(levelCode)) {//
		// 二级管理员
		// qCommond.setUnitLevel(TrainingClass.MECHANISM_TYPE_TWO);
		// }

		onAfterFindList(resultList, qCommond, request);
		// 存放结果
		qCommond.setResultList(resultList);
		resultState.setState(ResultState.RESULT_STATE_SUCCESS);
		return getModulePath() + "/list";
	}
}
